1 package net.sf.saxon.dom; 2 3 import net.sf.saxon.om.Axis; 4 import net.sf.saxon.om.AxisIterator; 5 import net.sf.saxon.om.NodeInfo; 6 import org.w3c.dom.DOMException ; 7 import org.w3c.dom.NamedNodeMap ; 8 import org.w3c.dom.Node ; 9 10 14 15 class DOMAttributeMap implements NamedNodeMap { 16 17 private NodeInfo parent; 18 19 22 23 public DOMAttributeMap(NodeInfo parent) { 24 this.parent = parent; 25 } 26 27 30 31 public Node getNamedItem(String name) { 32 AxisIterator atts = parent.iterateAxis(Axis.ATTRIBUTE); 33 while (true) { 34 NodeInfo att = (NodeInfo)atts.next(); 35 if (att == null) { 36 return null; 37 } 38 if (name.equals(att.getDisplayName())) { 39 return NodeOverNodeInfo.wrap(att); 40 } 41 } 42 } 43 44 48 49 public Node item(int index) { 50 if (index<0) { 51 return null; 52 } 53 int length = 0; 54 AxisIterator atts = parent.iterateAxis(Axis.ATTRIBUTE); 55 while (true) { 56 NodeInfo att = (NodeInfo)atts.next(); 57 if (att == null) { 58 return null; 59 } 60 if (length==index) { 61 return NodeOverNodeInfo.wrap(att); 62 } 63 length++; 64 } 65 } 66 67 70 71 public int getLength() { 72 int length = 0; 73 AxisIterator atts = parent.iterateAxis(Axis.ATTRIBUTE); 74 while (atts.next() != null) { 75 length++; 76 } 77 return length; 78 } 79 80 83 84 public Node getNamedItemNS(String uri, String localName) { 85 if (uri==null) uri=""; 86 AxisIterator atts = parent.iterateAxis(Axis.ATTRIBUTE); 87 while (true) { 88 NodeInfo att = (NodeInfo)atts.next(); 89 if (att == null) { 90 return null; 91 } 92 if (uri.equals(att.getURI()) && localName.equals(att.getLocalPart())) { 93 return NodeOverNodeInfo.wrap(att); 94 } 95 } 96 } 97 98 101 102 public Node setNamedItem(Node arg) throws DOMException { 103 NodeOverNodeInfo.disallowUpdate(); 104 return null; 105 } 106 107 110 111 public Node removeNamedItem(String name) throws DOMException { 112 NodeOverNodeInfo.disallowUpdate(); 113 return null; 114 } 115 116 119 120 public Node setNamedItemNS(Node arg) throws DOMException { 121 NodeOverNodeInfo.disallowUpdate(); 122 return null; 123 } 124 125 128 129 public Node removeNamedItemNS(String uri, String localName) throws DOMException { 130 NodeOverNodeInfo.disallowUpdate(); 131 return null; 132 } 133 134 } 135 136 154 | Popular Tags |