/** * Returns a map containing all attributes of the Node of this NodeChild. * @return a map containing all attributes */ public Map attributes() { return this.node.attributes(); }
/** * @param node a node * @param parent the GPathResult prior to the application of the expression creating this GPathResult * @param namespacePrefix the namespace prefix if any * @param namespaceTagHints the known tag to namespace mappings */ public NodeChild(final Node node, final GPathResult parent, final String namespacePrefix, final Map<String, String> namespaceTagHints) { super(parent, node.name(), namespacePrefix, namespaceTagHints); this.node = node; ((NamespaceAwareHashMap)this.node.attributes()).setNamespaceTagHints(namespaceTagHints); }
protected Object getNextNode(final Iterator iter) { while (iter.hasNext()) { final Object next = iter.next(); if (next instanceof Attribute) { return next; } else { String attributeKey = Attributes.this.attributeName; if (Attributes.this.namespacePrefix != null && !"*".equals(Attributes.this.namespacePrefix) && Attributes.this.namespacePrefix.length() > 0) { attributeKey = new QName(Attributes.this.lookupNamespace(Attributes.this.namespacePrefix), Attributes.this.attributeName).toString(); } final String value = (String) ((Node) next).attributes().get(attributeKey); if (value != null) { return new Attribute(Attributes.this.name, value, new NodeChild((Node) next, Attributes.this.parent.parent, "", Attributes.this.namespaceTagHints), (Attributes.this.namespacePrefix == null || "*".equals(Attributes.this.namespacePrefix)) ? "" : Attributes.this.namespacePrefix, Attributes.this.namespaceTagHints); } } } return null; } };
/** * Returns a map containing all attributes of the Node of this NodeChild. * @return a map containing all attributes */ public Map attributes() { return this.node.attributes(); }
public Map attributes() { return this.node.attributes(); }
public Map attributes() { return this.node.attributes(); }
public Map attributes() { return this.node.attributes(); }
public Map attributes() { return this.node.attributes(); }
/** * @param node a node * @param parent the GPathResult prior to the application of the expression creating this GPathResult * @param namespacePrefix the namespace prefix if any * @param namespaceTagHints the known tag to namespace mappings */ public NodeChild(final Node node, final GPathResult parent, final String namespacePrefix, final Map<String, String> namespaceTagHints) { super(parent, node.name(), namespacePrefix, namespaceTagHints); this.node = node; ((NamespaceAwareHashMap)this.node.attributes()).setNamespaceTagHints(namespaceTagHints); }
protected Object getNextNode(final Iterator iter) { while (iter.hasNext()) { final Object next = iter.next(); if (next instanceof Attribute) { return next; } else { final String value = (String) ((Node) next).attributes().get(Attributes.this.attributeName); if (value != null) { return new Attribute(Attributes.this.attributeName, value, new NodeChild((Node) next, Attributes.this.parent.parent, "", Attributes.this.namespaceTagHints), "", Attributes.this.namespaceTagHints); } } } return null; } };
protected Object getNextNode(final Iterator iter) { while (iter.hasNext()) { final Object next = iter.next(); if (next instanceof Attribute) { return next; } else { final String value = (String) ((Node) next).attributes().get(Attributes.this.attributeName); if (value != null) { return new Attribute(Attributes.this.attributeName, value, new NodeChild((Node) next, Attributes.this.parent.parent, "", Attributes.this.namespaceTagHints), "", Attributes.this.namespaceTagHints); } } } return null; } };
protected Object getNextNode(final Iterator iter) { while (iter.hasNext()) { final Object next = iter.next(); if (next instanceof Attribute) { return next; } else { final String value = (String) ((Node) next).attributes().get(Attributes.this.attributeName); if (value != null) { return new Attribute(Attributes.this.name, value, new NodeChild((Node) next, Attributes.this.parent.parent, "", Attributes.this.namespaceTagHints), "", Attributes.this.namespaceTagHints); } } } return null; } };
protected Object getNextNode(final Iterator iter) { while (iter.hasNext()) { final Object next = iter.next(); if (next instanceof Attribute) { return next; } else { final String value = (String) ((Node) next).attributes().get(Attributes.this.attributeName); if (value != null) { return new Attribute(Attributes.this.name, value, new NodeChild((Node) next, Attributes.this.parent.parent, "", Attributes.this.namespaceTagHints), "", Attributes.this.namespaceTagHints); } } } return null; } };
protected Object getNextNode(final Iterator iter) { while (iter.hasNext()) { final Object next = iter.next(); if (next instanceof Attribute) { return next; } else { String attributeKey = Attributes.this.attributeName; if (Attributes.this.namespacePrefix != null && !"*".equals(Attributes.this.namespacePrefix) && Attributes.this.namespacePrefix.length() > 0) { attributeKey = new QName(Attributes.this.lookupNamespace(Attributes.this.namespacePrefix), Attributes.this.attributeName).toString(); } final String value = (String) ((Node) next).attributes().get(attributeKey); if (value != null) { return new Attribute(Attributes.this.name, value, new NodeChild((Node) next, Attributes.this.parent.parent, "", Attributes.this.namespaceTagHints), (Attributes.this.namespacePrefix == null || "*".equals(Attributes.this.namespacePrefix)) ? "" : Attributes.this.namespacePrefix, Attributes.this.namespaceTagHints); } } } return null; } };
private void walkXml(IndentPrinter printer, Node node) { printer.printIndent(); printer.print(node.name()); if (!node.attributes().isEmpty()) { printer.print("("); List<String> attrs = new ArrayList<>(); for (Object o : node.attributes().entrySet()) { Map.Entry<?, ?> entry = (Map.Entry<?, ?>) o; attrs.add(entry.getKey() + ": " + entry.getValue()); printer.printIndent(); printer.println("}"); } else if (!node.attributes().isEmpty()) { printer.println(""); } else {