@Override public final XmlObject[] getAnyXmlObjects(QName qname) { XmlObject[] anyXmlObjects = getAnyXmlObjects(); List<XmlObject> result = new ArrayList<XmlObject>(); for (XmlObject anyXmlObject : anyXmlObjects) { if (!qname.equals(anyXmlObject.getXmlObjectQName())) continue; result.add(anyXmlObject); } return (XmlObject[]) result.toArray(new XmlObject[result.size()]); }
private static Definitions getParentDefinitions(XmlObject xo) { if (xo == null) { return null; } if (xo instanceof Definitions) { return (Definitions) xo; } return getParentDefinitions(xo.getXmlObjectParent()); }
XmlObjectAdoptionMediator(XmlObject xmlObject) { this.adoptedChildrenCache = new HashMap<String, XmlObject>(); URI baseURI = xmlObject.getXmlObjectBaseURI(); if (baseURI != null) { adoptedChildrenCache.put(makeAdoptedChildKey(baseURI, ""), xmlObject.getXmlObjectBaseRoot()); } this.xmlContext = (XmlContextImpl) xmlObject.getXmlContext(); }
private final int guessIndexFromParent(XmlObject newParent) { if (newParent == null) return 0; XmlObjectNode[] children = newParent.getXmlObjectNaturalChildren(); int i = 0; for (XmlObjectNode child : children) { if (child == this) { return i; } ++i; } children = newParent.getXmlObjectAdoptedChildren(); i = 0; for (XmlObjectNode child : children) { if (child == this) { return i; } ++i; } throw new UncheckedException("XML object has a parent but no index!"); }
@Override public Map<String, String> getXmlObjectInScopeNamespaces() { // TODO : could be cached and flushed on parent change! Map<String, String> namespaces = new HashMap<String, String>(); XmlObject current = this; while (true) { if (current == null) break; Node node = current.getXmlObjectDOMNode(); assert node != null; NamedNodeMap nodeMap = node.getAttributes(); for (int i = 0 ; i < nodeMap.getLength() ; ++i) { Node attrNode = nodeMap.item(i); if (XMLConstants.XMLNS_ATTRIBUTE.equals(attrNode.getPrefix())) { if (namespaces.containsKey(attrNode.getLocalName())) continue; namespaces.put(attrNode.getLocalName(), attrNode.getNodeValue()); } } current = current.getXmlObjectParent(); } return namespaces; }
URI baseURI = adoptiveParent.getXmlObjectBaseURI(); childToAdopt = resolveXPath(adoptiveParent.getXmlObjectRoot(), xpath); } else { XmlObjectReader reader = adoptiveParent.getXmlContext().createReader();
private XmlObject resolveXPath(XmlObject contextXmlObject, String xpath) { if (xpath.isEmpty()) return contextXmlObject; XmlObjectXPathEvaluator xpe = contextXmlObject.getXmlContext().createXPathEvaluator(); try { XmlObject childToAdopt = xpe.selectSingleXmlObjectNode(contextXmlObject, xpath, XmlObject.class); return childToAdopt; } catch (XPathExpressionException xpee) { throw new UncheckedException(String.format("Invalid XPath expression '%s'.", xpath)); } }
static AxisIterator createAttributeIterator(XmlObjectNode xmlObjectNode, NodeTest nodeTest, Configuration configuration) { if (!(xmlObjectNode instanceof XmlObject)) { return EMPTY_AXIS_ITERATOR; } Deque<NodeInfo> attributes = wrapXmlObjectAttributesAsNodeInfos((XmlObject) xmlObjectNode, ((XmlObject) xmlObjectNode).getXmlObjectAttributes(), configuration, nodeTest); return new NodeArrayIterator(attributes.toArray(new NodeInfo[attributes.size()])); }
static NodeInfo wrapXmlObjectAttributeAsNodeInfo(XmlObject xmlObject, QName key, Object value, Configuration configuration) { assert xmlObject != null; assert key != null; assert value != null; XmlObjectAttributeImpl xoa = new XmlObjectAttributeImpl( xmlObject.getXmlContext(), new AttributeModelObject(null, key, value)); // TODO : attributes should be included in children! return wrapXmlObjectAttributeAsNodeInfo(xoa, configuration); }
@Override public final XmlObject[] getAnyXmlObjects(QName qname) { XmlObject[] anyXmlObjects = getAnyXmlObjects(); List<XmlObject> result = new ArrayList<XmlObject>(); for (XmlObject anyXmlObject : anyXmlObjects) { if (!qname.equals(anyXmlObject.getXmlObjectQName())) continue; result.add(anyXmlObject); } return (XmlObject[]) result.toArray(new XmlObject[result.size()]); }
private static WithFlowElements getParentContainer(XmlObject xo) { if (xo == null) { return null; } if (xo instanceof WithFlowElements) { return (WithFlowElements) xo; } return getParentContainer(xo.getXmlObjectParent()); } }
@Override public final XmlObject[] getAnyXmlObjects(QName qname) { XmlObject[] anyXmlObjects = getAnyXmlObjects(); List<XmlObject> result = new ArrayList<XmlObject>(); for (XmlObject anyXmlObject : anyXmlObjects) { if (!qname.equals(anyXmlObject.getXmlObjectQName())) continue; result.add(anyXmlObject); } return (XmlObject[]) result.toArray(new XmlObject[result.size()]); }
private ComplexType findParentType(XmlObject childDefinition) { ComplexType parentType = null; XmlObject parent = childDefinition.getXmlObjectParent(); if (parent != null) { if (parent instanceof com.ebmwebsourcing.easyschema10.api.element.Element) { parentType = (ComplexType) ((com.ebmwebsourcing.easyschema10.api.element.Element) parent) .findType(); } else if (parent instanceof ComplexType) { parentType = (ComplexType) parent; } else { parentType = findParentType(parent); } } return parentType; }
@Override public final XmlObject[] getAnyXmlObjects(QName qname) { XmlObject[] anyXmlObjects = getAnyXmlObjects(); List<XmlObject> result = new ArrayList<XmlObject>(); for (XmlObject anyXmlObject : anyXmlObjects) { if (!qname.equals(anyXmlObject.getXmlObjectQName())) continue; result.add(anyXmlObject); } return (XmlObject[]) result.toArray(new XmlObject[result.size()]); }
@Override public final boolean hasAnyXmlObject(QName qname) { XmlObject[] anyXmlObjects = getAnyXmlObjects(); for (XmlObject anyXmlObject : anyXmlObjects) { if (qname.equals(anyXmlObject.getXmlObjectQName())) return true; } return false; }
@Override public final boolean hasAnyXmlObject(QName qname) { XmlObject[] anyXmlObjects = getAnyXmlObjects(); for (XmlObject anyXmlObject : anyXmlObjects) { if (qname.equals(anyXmlObject.getXmlObjectQName())) return true; } return false; }
@Override public final boolean hasAnyXmlObject(QName qname) { XmlObject[] anyXmlObjects = getAnyXmlObjects(); for (XmlObject anyXmlObject : anyXmlObjects) { if (qname.equals(anyXmlObject.getXmlObjectQName())) return true; } return false; }
@Override public final boolean hasAnyXmlObject(QName qname) { XmlObject[] anyXmlObjects = getAnyXmlObjects(); for (XmlObject anyXmlObject : anyXmlObjects) { if (qname.equals(anyXmlObject.getXmlObjectQName())) return true; } return false; }
@Override public final boolean hasAnyXmlObject(QName qname) { XmlObject[] anyXmlObjects = getAnyXmlObjects(); for (XmlObject anyXmlObject : anyXmlObjects) { if (qname.equals(anyXmlObject.getXmlObjectQName())) return true; } return false; }
@Override public final XmlObject[] getAnyXmlObjects(QName qname) { XmlObject[] anyXmlObjects = getAnyXmlObjects(); List<XmlObject> result = new ArrayList<XmlObject>(); for (XmlObject anyXmlObject : anyXmlObjects) { if (!qname.equals(anyXmlObject.getXmlObjectQName())) continue; result.add(anyXmlObject); } return (XmlObject[]) result.toArray(new XmlObject[result.size()]); }