1 16 19 package com.sun.org.apache.xpath.internal.functions; 20 21 import com.sun.org.apache.xml.internal.dtm.DTM; 22 import com.sun.org.apache.xpath.internal.XPathContext; 23 import com.sun.org.apache.xpath.internal.objects.XObject; 24 import com.sun.org.apache.xpath.internal.objects.XString; 25 26 30 public class FuncNamespace extends FunctionDef1Arg 31 { 32 33 41 public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException 42 { 43 44 int context = getArg0AsNode(xctxt); 45 46 String s; 47 if(context != DTM.NULL) 48 { 49 DTM dtm = xctxt.getDTM(context); 50 int t = dtm.getNodeType(context); 51 if(t == DTM.ELEMENT_NODE) 52 { 53 s = dtm.getNamespaceURI(context); 54 } 55 else if(t == DTM.ATTRIBUTE_NODE) 56 { 57 58 61 s = dtm.getNodeName(context); 62 if(s.startsWith("xmlns:") || s.equals("xmlns")) 63 return XString.EMPTYSTRING; 64 65 s = dtm.getNamespaceURI(context); 66 } 67 else 68 return XString.EMPTYSTRING; 69 } 70 else 71 return XString.EMPTYSTRING; 72 73 return ((null == s) ? XString.EMPTYSTRING : new XString(s)); 74 } 75 } 76 | Popular Tags |