/** * Get the index position of this node among its siblings (starting from 0) */ public int getSiblingPosition() { // This method is used only to support generate-id() if (index != -1) return index; switch (nodeKind) { case Type.ATTRIBUTE: { Attribute att = (Attribute) node; Element p = (Element) att.getParent(); if (p == null) return 0; for (int i = p.getAttributeCount(); --i >= 0; ) { if (p.getAttribute(i) == att) { index = i; return i; } } throw new IllegalStateException("XOM node not linked to parent node"); } default: { ParentNode p = node.getParent(); int i = (p == null ? 0 : p.indexOf(node)); if (i == -1) throw new IllegalStateException("XOM node not linked to parent node"); index = i; return index; } } }
/** * Get the index position of this node among its siblings (starting from 0) */ public int getSiblingPosition() { // This method is used only to support generate-id() if (index != -1) return index; switch (nodeKind) { case Type.ATTRIBUTE: { Attribute att = (Attribute) node; Element p = (Element) att.getParent(); if (p == null) return 0; for (int i = p.getAttributeCount(); --i >= 0; ) { if (p.getAttribute(i) == att) { index = i; return i; } } throw new IllegalStateException("XOM node not linked to parent node"); } default: { ParentNode p = node.getParent(); int i = (p == null ? 0 : p.indexOf(node)); if (i == -1) throw new IllegalStateException("XOM node not linked to parent node"); index = i; return index; } } }
/** * Get the index position of this node among its siblings (starting from 0) */ public int getSiblingPosition() { // This method is used only to support generate-id() if (index != -1) return index; switch (nodeKind) { case Type.ATTRIBUTE: { Attribute att = (Attribute) node; Element p = (Element) att.getParent(); if (p == null) return 0; for (int i = p.getAttributeCount(); --i >= 0; ) { if (p.getAttribute(i) == att) { index = i; return i; } } throw new IllegalStateException("XOM node not linked to parent node"); } default: { ParentNode p = node.getParent(); int i = (p == null ? 0 : p.indexOf(node)); if (i == -1) throw new IllegalStateException("XOM node not linked to parent node"); index = i; return index; } } }
void substituteNameByValue(Attribute att) { // do not substitute refs if (att instanceof RefAttribute) { } else { String value = att.getValue(); String value1 = value; String newValue = this.getValue().trim(); if (!newValue.equals(S_EMPTY)) { value1 = value1.replaceAll(S_UNDER+this.getName()+S_UNDER, newValue); if (!value.equals(value1)) { Element parent = (Element) att.getParent(); // remove attribute so as not to triffer reset error parent.removeAttribute(parent.getAttribute(att.getLocalName())); att.setValue(value1); parent.addAttribute(att); } else { } } } }
ParentNode parent = this.getParent(); if (parent != null) {