KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xpath > internal > functions > FuncExtElementAvailable


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.sun.org.apache.xpath.internal.functions;
17
18 import com.sun.org.apache.xalan.internal.templates.Constants;
19 //import com.sun.org.apache.xalan.internal.transformer.TransformerImpl;
20
import com.sun.org.apache.xml.internal.utils.QName;
21 import com.sun.org.apache.xpath.internal.ExtensionsProvider;
22 import com.sun.org.apache.xpath.internal.XPathContext;
23 import com.sun.org.apache.xpath.internal.objects.XBoolean;
24 import com.sun.org.apache.xpath.internal.objects.XObject;
25
26 /**
27  * Execute the ExtElementAvailable() function.
28  * @xsl.usage advanced
29  */

30 public class FuncExtElementAvailable extends FunctionOneArg
31 {
32
33   /**
34    * Execute the function. The function must return
35    * a valid object.
36    * @param xctxt The current execution context.
37    * @return A valid XObject.
38    *
39    * @throws javax.xml.transform.TransformerException
40    */

41   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException JavaDoc
42   {
43
44     String JavaDoc prefix;
45     String JavaDoc namespace;
46     String JavaDoc methName;
47
48     String JavaDoc fullName = m_arg0.execute(xctxt).str();
49     int indexOfNSSep = fullName.indexOf(':');
50
51     if (indexOfNSSep < 0)
52     {
53       prefix = "";
54       namespace = Constants.S_XSLNAMESPACEURL;
55       methName = fullName;
56     }
57     else
58     {
59       prefix = fullName.substring(0, indexOfNSSep);
60       namespace = xctxt.getNamespaceContext().getNamespaceForPrefix(prefix);
61       if (null == namespace)
62         return XBoolean.S_FALSE;
63       methName= fullName.substring(indexOfNSSep + 1);
64     }
65
66     if (namespace.equals(Constants.S_XSLNAMESPACEURL)
67     || namespace.equals(Constants.S_BUILTIN_EXTENSIONS_URL))
68     {
69           // <<<<<<< TIGER SPECIFIC CHANGE >>>>>>>>>
70
// As we are not supporting Xalan interpretive we are taking away the functionality
71
// dependent on XSLT interpretive Transformer. Only way supported is to use XSLTC
72
// and the execution path needed for supporting standard XPath API defined by
73
// JAXP 1.3 . This method is overridden in XPath implementation to support
74
// standard XPath functionality with xpath package of Xalan
75

76         return XBoolean.S_FALSE;
77     }
78     else
79     {
80       //dml
81
ExtensionsProvider extProvider = (ExtensionsProvider)xctxt.getOwnerObject();
82       return extProvider.elementAvailable(namespace, methName)
83              ? XBoolean.S_TRUE : XBoolean.S_FALSE;
84     }
85   }
86 }
87
Popular Tags