/** * Returns the QName of an element, possibly using the given metadata for * the name if it is not {@code null}. */ protected QName getName(Element e, ElementMetadata<?, ?> metadata) { return (metadata == null) ? e.getElementId() : metadata.getName(); }
/** * Returns the QName of an element, possibly using the given metadata for * the name if it is not {@code null}. */ protected QName getName(Element e, ElementMetadata<?, ?> metadata) { return (metadata == null) ? e.getElementId() : metadata.getName(); }
/** * Returns the QName of an element, possibly using the given metadata for * the name if it is not {@code null}. */ protected QName getName(Element e, ElementMetadata<?, ?> metadata) { return (metadata == null) ? e.getElementId() : metadata.getName(); }
public QName getName() { return delegate().getName(); }
public QName getName() { return delegate().getName(); }
public QName getName() { return delegate().getName(); }
private static void addReferencedNamespaces(ElementMetadata<?, ?> metadata, ImmutableSet.Builder<XmlNamespace> builder, Set<ElementKey<?, ?>> added) { // Avoid recursive looping if (added.contains(metadata.getKey())) { return; } added.add(metadata.getKey()); // Add namespace for this element (if any) XmlNamespace elemNs = metadata.getName().getNs(); if (elemNs != null) { builder.add(elemNs); } // Add namespace for all attributes (if any) for (AttributeKey<?> attrKey : metadata.getAttributes()) { AttributeMetadata<?> attrMetadata = metadata.bindAttribute(attrKey); XmlNamespace attrNs = attrMetadata.getName().getNs(); if (attrNs != null) { builder.add(attrNs); } } // Add namespace for all child elements (recursively) for (ElementKey<?, ?> elemKey : metadata.getElements()) { ElementMetadata<?, ?> childMetadata = metadata.bindElement(elemKey); addReferencedNamespaces(childMetadata, builder, added); } }
private static void addReferencedNamespaces(ElementMetadata<?, ?> metadata, ImmutableSet.Builder<XmlNamespace> builder, Set<ElementKey<?, ?>> added) { // Avoid recursive looping if (added.contains(metadata.getKey())) { return; } added.add(metadata.getKey()); // Add namespace for this element (if any) XmlNamespace elemNs = metadata.getName().getNs(); if (elemNs != null) { builder.add(elemNs); } // Add namespace for all attributes (if any) for (AttributeKey<?> attrKey : metadata.getAttributes()) { AttributeMetadata<?> attrMetadata = metadata.bindAttribute(attrKey); XmlNamespace attrNs = attrMetadata.getName().getNs(); if (attrNs != null) { builder.add(attrNs); } } // Add namespace for all child elements (recursively) for (ElementKey<?, ?> elemKey : metadata.getElements()) { ElementMetadata<?, ?> childMetadata = metadata.bindElement(elemKey); addReferencedNamespaces(childMetadata, builder, added); } }
private static void addReferencedNamespaces(ElementMetadata<?, ?> metadata, ImmutableSet.Builder<XmlNamespace> builder, Set<ElementKey<?, ?>> added) { // Avoid recursive looping if (added.contains(metadata.getKey())) { return; } added.add(metadata.getKey()); // Add namespace for this element (if any) XmlNamespace elemNs = metadata.getName().getNs(); if (elemNs != null) { builder.add(elemNs); } // Add namespace for all attributes (if any) for (AttributeKey<?> attrKey : metadata.getAttributes()) { AttributeMetadata<?> attrMetadata = metadata.bindAttribute(attrKey); XmlNamespace attrNs = attrMetadata.getName().getNs(); if (attrNs != null) { builder.add(attrNs); } } // Add namespace for all child elements (recursively) for (ElementKey<?, ?> elemKey : metadata.getElements()) { ElementMetadata<?, ?> childMetadata = metadata.bindElement(elemKey); addReferencedNamespaces(childMetadata, builder, added); } }
/** * Calculate the namespaces on an element using the given visitor to store * the namespaces. We cheat by using an attribute visitor for even visiting * the element names, because all we're doing with the visitor is adding a * QName. */ private static void calculateNamespaces(Map<String, XmlNamespace> namespaces, Element e, ElementMetadata<?, ?> metadata) { QName name = (metadata == null) ? e.getElementId() : metadata.getName(); addNamespace(namespaces, name); Iterator<Attribute> attIter = e.getAttributeIterator(metadata); while (attIter.hasNext()) { Attribute att = attIter.next(); AttributeKey<?> attKey = att.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); name = (attMeta == null) ? attKey.getId() : attMeta.getName(); addNamespace(namespaces, name); } Iterator<Element> childIter = e.getElementIterator(metadata); while (childIter.hasNext()) { Element child = childIter.next(); ElementMetadata<?, ?> childMeta = (metadata == null) ? null : metadata.bindElement(child.getElementKey()); calculateNamespaces(namespaces, child, childMeta); } }
/** * Calculate the namespaces on an element using the given visitor to store * the namespaces. We cheat by using an attribute visitor for even visiting * the element names, because all we're doing with the visitor is adding a * QName. */ private static void calculateNamespaces(Map<String, XmlNamespace> namespaces, Element e, ElementMetadata<?, ?> metadata) { QName name = (metadata == null) ? e.getElementId() : metadata.getName(); addNamespace(namespaces, name); Iterator<Attribute> attIter = e.getAttributeIterator(metadata); while (attIter.hasNext()) { Attribute att = attIter.next(); AttributeKey<?> attKey = att.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); name = (attMeta == null) ? attKey.getId() : attMeta.getName(); addNamespace(namespaces, name); } Iterator<Element> childIter = e.getElementIterator(metadata); while (childIter.hasNext()) { Element child = childIter.next(); ElementMetadata<?, ?> childMeta = (metadata == null) ? null : metadata.bindElement(child.getElementKey()); calculateNamespaces(namespaces, child, childMeta); } }
/** * Calculate the namespaces on an element using the given visitor to store * the namespaces. We cheat by using an attribute visitor for even visiting * the element names, because all we're doing with the visitor is adding a * QName. */ private static void calculateNamespaces(Map<String, XmlNamespace> namespaces, Element e, ElementMetadata<?, ?> metadata) { QName name = (metadata == null) ? e.getElementId() : metadata.getName(); addNamespace(namespaces, name); Iterator<Attribute> attIter = e.getAttributeIterator(metadata); while (attIter.hasNext()) { Attribute att = attIter.next(); AttributeKey<?> attKey = att.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); name = (attMeta == null) ? attKey.getId() : attMeta.getName(); addNamespace(namespaces, name); } Iterator<Element> childIter = e.getElementIterator(metadata); while (childIter.hasNext()) { Element child = childIter.next(); ElementMetadata<?, ?> childMeta = (metadata == null) ? null : metadata.bindElement(child.getElementKey()); calculateNamespaces(namespaces, child, childMeta); } }
public Element parse(Element element) throws IOException, ParseException, ContentValidationException { ValidationContext vc = new ValidationContext(); ElementMetadata<?, ?> metadata = props.getRootMetadata(); this.rootHandler = createRootHandler(vc, element, metadata); QName elementName = (metadata == null) ? element.getElementId() : metadata.getName(); XmlNamespace elementNs = elementName.getNs(); this.rootNamespace = elementNs == null ? null : elementNs.getUri(); this.rootElementName = elementName.getLocalName(); try { eventSource.parse(this); } catch (SAXException e) { Exception rootException = e.getException(); if (rootException instanceof ParseException) { throwParseException((ParseException) rootException); } else if (rootException instanceof IOException) { LogUtils.logException(logger, Level.WARNING, null, e); throw (IOException) rootException; } else { LogUtils.logException(logger, Level.FINE, null, e); throw new ParseException(e); } } return element.resolve(metadata); }
public Element parse(Element element) throws IOException, ParseException, ContentValidationException { ValidationContext vc = new ValidationContext(); ElementMetadata<?, ?> metadata = props.getRootMetadata(); this.rootHandler = createRootHandler(vc, element, metadata); QName elementName = (metadata == null) ? element.getElementId() : metadata.getName(); XmlNamespace elementNs = elementName.getNs(); this.rootNamespace = elementNs == null ? null : elementNs.getUri(); this.rootElementName = elementName.getLocalName(); try { eventSource.parse(this); } catch (SAXException e) { Exception rootException = e.getException(); if (rootException instanceof ParseException) { throwParseException((ParseException) rootException); } else if (rootException instanceof IOException) { LogUtils.logException(logger, Level.WARNING, null, e); throw (IOException) rootException; } else { LogUtils.logException(logger, Level.FINE, null, e); throw new ParseException(e); } } return element.resolve(metadata); }
public Element parse(Element element) throws IOException, ParseException, ContentValidationException { ValidationContext vc = new ValidationContext(); ElementMetadata<?, ?> metadata = props.getRootMetadata(); this.rootHandler = createRootHandler(vc, element, metadata); QName elementName = (metadata == null) ? element.getElementId() : metadata.getName(); XmlNamespace elementNs = elementName.getNs(); this.rootNamespace = elementNs == null ? null : elementNs.getUri(); this.rootElementName = elementName.getLocalName(); try { eventSource.parse(this); } catch (SAXException e) { Exception rootException = e.getException(); if (rootException instanceof ParseException) { throwParseException((ParseException) rootException); } else if (rootException instanceof IOException) { LogUtils.logException(logger, Level.WARNING, null, e); throw (IOException) rootException; } else { LogUtils.logException(logger, Level.FINE, null, e); throw new ParseException(e); } } return element.resolve(metadata); }