Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 package com.icl.saxon.tree; 2 import com.icl.saxon.om.NodeInfo; 3 4 import com.icl.saxon.output.Outputter; 5 6 import org.w3c.dom.Attr ; 7 import org.w3c.dom.Node ; 8 import org.w3c.dom.Element ; 9 import org.w3c.dom.DOMException ; 10 11 import javax.xml.transform.TransformerException ; 12 13 14 19 20 final class AttributeImpl extends NodeImpl implements Attr { 21 22 private int nameCode; 23 private String value; 24 25 33 34 public AttributeImpl(ElementImpl element, int index) { 35 parent = element; 36 this.index = index; 37 AttributeCollection atts = (AttributeCollection)element.getAttributeList(); 38 this.nameCode = atts.getNameCode(index); 39 this.value = atts.getValue(index); 40 } 41 42 45 46 public int getNameCode() { 47 return nameCode; 48 } 49 50 55 56 public boolean isSameNode(NodeInfo other) { 57 if (!(other instanceof AttributeImpl)) return false; 58 if (this==other) return true; 59 AttributeImpl otherAtt = (AttributeImpl)other; 60 return (parent.isSameNode(otherAtt.parent) && 61 ((nameCode&0xfffff)==(otherAtt.nameCode&0xfffff))); 62 } 63 64 70 71 protected long getSequenceNumber() { 72 return parent.getSequenceNumber() + 0x8000 + index; 73 } 75 76 80 81 public final short getNodeType() { 82 return ATTRIBUTE; 83 } 84 85 89 90 public String getStringValue() { 91 return value; 92 } 93 94 97 98 public Node getNextSibling() { 99 return null; 100 } 101 102 105 106 public Node getPreviousSibling() { 107 return null; 108 } 109 110 113 114 public NodeImpl getPreviousInDocument() { 115 return (NodeImpl)getParent(); 116 } 117 118 121 122 public NodeImpl getNextInDocument(NodeImpl anchor) { 123 if (this==anchor) return null; 124 return ((NodeImpl)getParent()).getNextInDocument(anchor); 125 } 126 127 130 131 public String generateId() { 132 return parent.generateId() + "_" + getDisplayName(); 133 } 134 135 138 139 public void copy(Outputter out) throws TransformerException { 140 int nameCode = getNameCode(); 141 if ((nameCode>>20 & 0xff) != 0) { nameCode = out.checkAttributePrefix(nameCode); 144 } 145 out.writeAttribute(nameCode, getStringValue()); 146 } 147 148 } 149 150
| Popular Tags
|