1 package net.sf.saxon.functions; 2 import net.sf.saxon.expr.XPathContext; 3 import net.sf.saxon.om.InscopeNamespaceResolver; 4 import net.sf.saxon.om.Item; 5 import net.sf.saxon.om.NamespaceResolver; 6 import net.sf.saxon.om.NodeInfo; 7 import net.sf.saxon.trans.XPathException; 8 import net.sf.saxon.value.AnyURIValue; 9 10 11 14 15 public class NamespaceForPrefix extends SystemFunction { 16 17 24 25 public Item evaluateItem(XPathContext context) throws XPathException { 26 NodeInfo element = (NodeInfo)argument[1].evaluateItem(context); 27 String prefix = argument[0].evaluateItem(context).getStringValue(); 28 if (prefix == null) { 29 return null; 30 } 31 NamespaceResolver resolver = new InscopeNamespaceResolver(element); 32 String uri = resolver.getURIForPrefix(prefix, true); 33 if (uri == null) { 34 return null; 35 } 36 return new AnyURIValue(uri); 37 } 38 39 } 40 41 | Popular Tags |