1 package net.sf.saxon.om; 2 3 import java.util.ArrayList ; 4 import java.util.Iterator ; 5 import java.util.List ; 6 7 11 public class InscopeNamespaceResolver implements NamespaceResolver { 12 13 private NodeInfo node; 14 15 public InscopeNamespaceResolver(NodeInfo node) { 16 this.node = node; 17 } 18 19 29 30 public String getURIForPrefix(String prefix, boolean useDefault) { 31 if ("".equals(prefix) && !useDefault) { 32 return ""; 33 } 34 AxisIterator iter = node.iterateAxis(Axis.NAMESPACE); 35 while (true) { 36 NodeInfo node = (NodeInfo)iter.next(); 37 if (node == null) { 38 break; 39 } 40 if (node.getLocalPart().equals(prefix)) { 41 return node.getStringValue(); 42 } 43 } 44 if ("".equals(prefix)) { 45 return ""; 46 } else { 47 return null; 48 } 49 } 50 51 55 56 public Iterator iteratePrefixes() { 57 List list = new ArrayList (16); 58 AxisIterator iter = node.iterateAxis(Axis.NAMESPACE); 59 while (true) { 60 NodeInfo node = (NodeInfo)iter.next(); 61 if (node == null) { 62 break; 63 } 64 list.add(node.getLocalPart()); 65 } 66 return list.iterator(); 67 } 68 69 72 73 public NodeInfo getNode() { 74 return node; 75 } 76 } 77 78 79 | Popular Tags |