1 16 19 package org.apache.xpath.functions; 20 21 import org.apache.xalan.templates.Constants; 22 import org.apache.xpath.ExtensionsProvider; 23 import org.apache.xpath.XPathContext; 24 import org.apache.xpath.compiler.Keywords; 25 import org.apache.xpath.objects.XBoolean; 26 import org.apache.xpath.objects.XObject; 27 28 32 public class FuncExtFunctionAvailable extends FunctionOneArg 33 { 34 35 43 public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException 44 { 45 46 String prefix; 47 String namespace; 48 String methName; 49 50 String fullName = m_arg0.execute(xctxt).str(); 51 int indexOfNSSep = fullName.indexOf(':'); 52 53 if (indexOfNSSep < 0) 54 { 55 prefix = ""; 56 namespace = Constants.S_XSLNAMESPACEURL; 57 methName = fullName; 58 } 59 else 60 { 61 prefix = fullName.substring(0, indexOfNSSep); 62 namespace = xctxt.getNamespaceContext().getNamespaceForPrefix(prefix); 63 if (null == namespace) 64 return XBoolean.S_FALSE; 65 methName = fullName.substring(indexOfNSSep + 1); 66 } 67 68 if (namespace.equals(Constants.S_XSLNAMESPACEURL)) 69 { 70 try 71 { 72 return Keywords.functionAvailable(methName) ? XBoolean.S_TRUE : XBoolean.S_FALSE; 73 } 74 catch (Exception e) 75 { 76 return XBoolean.S_FALSE; 77 } 78 } 79 else 80 { 81 ExtensionsProvider extProvider = (ExtensionsProvider)xctxt.getOwnerObject(); 83 return extProvider.functionAvailable(namespace, methName) 84 ? XBoolean.S_TRUE : XBoolean.S_FALSE; 85 } 86 } 87 } 88 | Popular Tags |