2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
19
* $Id: FuncExtElementAvailable.java,v 1.2 2009/12/10 03:18:13 matthewoliver Exp $
21
package org.apache.xpath.functions;
23
import org.apache.xalan.templates.Constants;
24
import org.apache.xalan.transformer.TransformerImpl;
25
import org.apache.xml.utils.QName;
26
import org.apache.xpath.ExtensionsProvider;
27
import org.apache.xpath.XPathContext;
28
import org.apache.xpath.objects.XBoolean;
29
import org.apache.xpath.objects.XObject;
32
* Execute the ExtElementAvailable() function.
35
public class FuncExtElementAvailable extends FunctionOneArg
37
static final long serialVersionUID = -472533699257968546L;
40
* Execute the function. The function must return
42
* @param xctxt The current execution context.
43
* @return A valid XObject.
45
* @throws javax.xml.transform.TransformerException
47
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
54
String fullName = m_arg0.execute(xctxt).str();
55
int indexOfNSSep = fullName.indexOf(':');
60
namespace = Constants.S_XSLNAMESPACEURL;
65
prefix = fullName.substring(0, indexOfNSSep);
66
namespace = xctxt.getNamespaceContext().getNamespaceForPrefix(prefix);
67
if (null == namespace)
68
return XBoolean.S_FALSE;
69
methName= fullName.substring(indexOfNSSep + 1);
72
if (namespace.equals(Constants.S_XSLNAMESPACEURL)
73
|| namespace.equals(Constants.S_BUILTIN_EXTENSIONS_URL))
77
TransformerImpl transformer = (TransformerImpl) xctxt.getOwnerObject();
78
return transformer.getStylesheet().getAvailableElements().containsKey(
79
new QName(namespace, methName))
80
? XBoolean.S_TRUE : XBoolean.S_FALSE;
84
return XBoolean.S_FALSE;
90
ExtensionsProvider extProvider = (ExtensionsProvider)xctxt.getOwnerObject();
91
return extProvider.elementAvailable(namespace, methName)
92
? XBoolean.S_TRUE : XBoolean.S_FALSE;