本文整理汇总了Java中org.dom4j.Element.getQualifiedName方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getQualifiedName方法的具体用法?Java Element.getQualifiedName怎么用?Java Element.getQualifiedName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.Element
的用法示例。
在下文中一共展示了Element.getQualifiedName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOccurrencesCount
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Gets the occurrencesCount attribute of the ChoiceGuard object
*
* @param name NOT YET DOCUMENTED
* @return The occurrencesCount value
*/
public final int getOccurrencesCount(String name) {
prtln("\ngetOccurrencesCount for name: " + name);
int cnt = 0;
if (occurrences != null) {
for (int i = 0; i < occurrences.size(); i++) {
Occurrence o = (Occurrence) occurrences.get(i);
if (o.elements != null) {
for (Iterator elements = o.elements.iterator(); elements.hasNext(); ) {
Element member = (Element) elements.next();
String memberName = member.getQualifiedName();
prtln("\t memberName: " + memberName);
if (name.equals(memberName))
cnt++;
}
}
}
}
prtln("... getOccurrencesCount for " + name + " returning " + cnt + "\n");
return cnt;
}
示例2: getRepeatingComplexSingletonChildName
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Gets the qualified element name of the repeatingComplexSingleton child of
* the node specified by the provided path, or an empty string if such a child
* does not exist.
*
* @param xpath NOT YET DOCUMENTED
* @return The repeatingComplexSingletonChildName value
*/
public String getRepeatingComplexSingletonChildName(String xpath) {
String normalizedXPath = XPathUtils.normalizeXPath(xpath);
Node instanceDocNode = getInstanceDocNode(normalizedXPath);
if (instanceDocNode != null && instanceDocNode.getNodeType() == org.dom4j.Node.ELEMENT_NODE) {
List children = ((Element) instanceDocNode).elements();
if (children.size() == 1) {
Element childElement = (Element) children.get(0);
String childPath = childElement.getPath();
SchemaNode schemaNode = getSchemaNode(childPath);
if (schemaNode != null && schemaNode.getTypeDef().isComplexType() && isRepeatingElement(childPath))
return childElement.getQualifiedName();
}
}
return "";
}
示例3: resolveElementName
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* If the child is an substitution element, then return the Head Element's
* qualified name, otherwise just use the child's qualified name
*
* @param parentPath NOT YET DOCUMENTED
* @param element NOT YET DOCUMENTED
* @return NOT YET DOCUMENTED
*/
private String resolveElementName(String parentPath, Element element) {
String qualifiedName = element.getQualifiedName();
if (schemaHelper == null)
return qualifiedName;
String xpath = parentPath + "/" + qualifiedName;
SchemaNode schemaNode = schemaHelper.getSchemaNode(xpath);
if (schemaNode == null) {
// prtln ("\t schemaNode not found: returning " + qualifiedName);
return qualifiedName;
}
if (schemaNode.getHeadElementName().length() > 0) {
// prtln ("\t this HAS a head element" + Dom4jUtils.prettyPrint (element));
return schemaNode.getHeadElementName();
}
else {
// prtln ("this did not have a head element");
return qualifiedName;
}
}
示例4: getOccurrences
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Returns a list of occurrence instances that can be used to determine
* whether an instance document element satisfies the occurrence constraints
* of the schema.<p>
* Walk down the buckets, when there is no room to add the current member,
* start an new occurrance. NOTE: the order in which we add members is
* aribitrary - we just can't overfill any single member.<p>
NOTE: this does not account for many of the children choice compositors can have:
- choice
- sequence
- any
- element
- group
*
*@return The occurrences value
*@exception Exception NOT YET DOCUMENTED
*/
protected List getOccurrences() throws Exception {
List occurrences = new ArrayList();
Occurrence o = null;
Iterator iMembers = this.instanceMembers.iterator();
/* compositor.getLeafMemberNames(); */
CompositorMember lastCM = null;
while (iMembers.hasNext()) {
Element memberElement = (Element) iMembers.next();
String leafName = memberElement.getQualifiedName();
// sanity check - must find a member for this child
if (!compositor.getLeafMemberNames().contains(leafName)) {
throw new Exception("Unexpected child element: \"" + leafName + "\"");
}
CompositorMember cm = compositor.getMember (leafName);
if (cm == null)
throw new Exception("Could not find CM for: \"" + leafName + "\"");
if (cm != lastCM || o.getMemberCount (cm) == cm.maxOccurs) {
// start a new occurrence
o = new Occurrence(compositor);
occurrences.add (o);
}
o.add (memberElement);
lastCM = cm;
}
return occurrences;
}
示例5: getOccurrences
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Returns a list of occurrence instances that can be used to determine whether an instance document element
* satisfies the occurrence constraints of the schema.
*
* @return The occurrences value
* @exception Exception NOT YET DOCUMENTED
*/
protected List getOccurrences() throws Exception {
prtln ("getOccurrences()");
occurrenceCounter = new OccurrenceCounter();
occurrences = new ArrayList();
List membersSeen = new ArrayList();
List elements = instanceMembers;
// walk down the elements
// we don't want to see any member twice, and no group should have more than one element
Occurrence occurrence = null;
if (elements.size() > 0) {
occurrence = new Occurrence ();
for (Iterator i = instanceMembers.iterator(); i.hasNext(); ) {
Element element = (Element) i.next();
// String name = element.getName();
String name = element.getQualifiedName();
if (compositor.getMember(name) == null || membersSeen.contains(name))
throw new Exception ("Unexpected child element: \"" + name + "\"");
membersSeen.add (name);
occurrence.elements.add (element);
}
occurrences.add (occurrence);
}
prtln ("getOccurrences returning " + this.occurrences.size());
return occurrences;
}
示例6: getCMBuckets
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Returns a list of element CMBuckets (representing contiguous elements
* belonging to the same top-level (the children of the compositor element)
* member.<p>
*
* E.g., if the top-level member is a sequence compositor, then as long as
* instanceElements belong to that compositor (i.e., they are in the set of
* leafMembersNames) we collect them in the same bucket.<p>
*
* Each bucket instance keeps track of how many elements it contains. Later,
* the buckets list is split into Occurrences.
*
* @return CMBuckets found in the instance document element to
* be tested
* @exception Exception NOT YET DOCUMENTED
*/
private List getCMBuckets() throws Exception {
// first pass - aggregate instanceElement children into buckets
List buckets = new ArrayList();
CompositorMember lastCM = null;
CMBucket currentBucket = null;
CompositorMember currentMember = null;
for (Iterator i = instanceMembers.iterator(); i.hasNext(); ) {
Element child = (Element) i.next();
String name = child.getQualifiedName();
// prtln ("compositorMemberName: " + name);
// sanity check - must find a member for this child
if (!compositor.getLeafMemberNames().contains(name)) {
// prtln (" .. not found but maybe it's an any type");
if (!compositor.hasAnyTypeMember())
throw new Exception("Unexpected child element: \"" + name + "\"");
}
CompositorMember cm = resolveLeafNameToCM(name);
if (cm == null) {
throw new Exception("CompositorMember (cm) not found for \"" + name + "\"");
}
// create a new bucket if the cm has changed AND
// the cmType has also changed.
// -- new buckets NOT added for adjacent ELEMENT compositors
if (cm != lastCM) {
// we're looking at a different CompositorMember. Create a
// new bucket UNLESS ...
if (lastCM != null &&
!lastCM.hasSubCompositor() &&
!cm.hasSubCompositor()) {
// do not create a new bucket for adjacent ELEMENTs
}
else {
// prtln ("\t ** adding new bucket");
currentBucket = new CMBucket(cm);
buckets.add(currentBucket);
}
lastCM = cm;
}
currentBucket.add(child);
}
// prtln(buckets.size() + " buckets after FIRST pass ....");
// printCMBuckets(buckets);
return buckets;
}
示例7: initializeChildren
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Initialize children of the element specified by path - note: we must
* manually add indexing for repeating elements
*
*@param path xpath to element whose children are to be processed
*@param element instance document element at path
*/
private void initializeChildren(String path, Element element) {
prtln ("initializeChildren() " + path);
SchemaNode parentNode = sh.getSchemaNode(path);
/*
* otherChildrenNames used to collect the member names that are NOT
* present in the instance document
*/
List otherChildrenNames = new ArrayList();
if (parentNode != null && parentNode.hasCompositor()) {
otherChildrenNames.addAll(parentNode.getCompositor().getLeafMemberNames());
}
Iterator elementIter = element.elementIterator();
String lastChildName = "";
int index = -1;
while (elementIter.hasNext()) {
Element child = (Element) elementIter.next();
String childName = child.getQualifiedName();
String childPath = path + "/" + childName;
if (!lastChildName.equals(childName)) {
lastChildName = childName;
index = 1;
}
otherChildrenNames.remove(childName);
SchemaNode schemaNode = sh.getSchemaNode(childPath);
if (schemaNode != null) {
boolean doInitialize = true;
GlobalDef typeDef = sh.getGlobalDef(schemaNode);
if (typeDef == null) {
doInitialize = true;
} else if (typeDef.isComplexType()) {
doInitialize = true;
} else if (sh.isMultiSelect(schemaNode)) {
doInitialize = true;
}
// duh - it is ALWAYS true!
if (!doInitialize) {
continue;
}
// for repeating items we have to add indexing to the path
if (sh.isRepeatingElement(schemaNode)) {
childPath += "[" + index++ + "]";
}
} else {
prtlnErr("schemaNode not found at " + childPath);
}
// recurse with childPath
initializePath(childPath);
}
// set displayState of otherChildren to open so their "add" controls will be available
if (!otherChildrenNames.isEmpty()) {
for (Iterator j = otherChildrenNames.iterator(); j.hasNext(); ) {
String encodedPath = XPathUtils.encodeXPath(path + "/" + (String) j.next());
this.openElement(encodedPath);
}
}
}
示例8: writeElement
import org.dom4j.Element; //导入方法依赖的package包/类
protected void writeElement(Element element) throws IOException {
int size = element.nodeCount();
String qualifiedName = element.getQualifiedName();
writePrintln();
indent();
writer.write("<");
writer.write(qualifiedName);
boolean textOnly = true;
for (int i = 0; i < size; i++) {
Node node = element.node(i);
if (node instanceof Element) {
textOnly = false;
} else if (node instanceof Comment) {
textOnly = false;
}
}
writeAttributes(element);
lastOutputNodeType = Node.ELEMENT_NODE;
if (size <= 0) {
writeEmptyElementClose(qualifiedName);
} else {
writer.write(">");
if (textOnly) {
// we have at least one text node so lets assume
// that its non-empty
writeElementContent(element);
} else {
if (element.attributeCount() > 3)
writePrintln();
// we know it's not null or empty from above
++indentLevel;
writeElementContent(element);
--indentLevel;
writePrintln();
indent();
}
writer.write("</");
writer.write(qualifiedName);
writer.write(">");
}
if (element.attributeCount() > 2 && indentLevel > 0)
writePrintln();
lastOutputNodeType = Node.ELEMENT_NODE;
}