286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 1999-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A/*
286N/A * $Id: FuncExtElementAvailable.java,v 1.2.4.1 2005/09/14 19:58:32 jeffsuttor Exp $
286N/A */
286N/Apackage com.sun.org.apache.xpath.internal.functions;
286N/A
286N/Aimport com.sun.org.apache.xalan.internal.templates.Constants;
286N/A// J2SE does not support Xalan interpretive
286N/A/*
286N/Aimport com.sun.org.apache.xalan.internal.transformer.TransformerImpl;
286N/A*/
286N/Aimport com.sun.org.apache.xml.internal.utils.QName;
286N/Aimport com.sun.org.apache.xpath.internal.ExtensionsProvider;
286N/Aimport com.sun.org.apache.xpath.internal.XPathContext;
286N/Aimport com.sun.org.apache.xpath.internal.objects.XBoolean;
286N/Aimport com.sun.org.apache.xpath.internal.objects.XObject;
286N/A
286N/A/**
286N/A * Execute the ExtElementAvailable() function.
286N/A * @xsl.usage advanced
286N/A */
286N/Apublic class FuncExtElementAvailable extends FunctionOneArg
286N/A{
286N/A static final long serialVersionUID = -472533699257968546L;
286N/A
286N/A /**
286N/A * Execute the function. The function must return
286N/A * a valid object.
286N/A * @param xctxt The current execution context.
286N/A * @return A valid XObject.
286N/A *
286N/A * @throws javax.xml.transform.TransformerException
286N/A */
286N/A public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
286N/A {
286N/A
286N/A String prefix;
286N/A String namespace;
286N/A String methName;
286N/A
286N/A String fullName = m_arg0.execute(xctxt).str();
286N/A int indexOfNSSep = fullName.indexOf(':');
286N/A
286N/A if (indexOfNSSep < 0)
286N/A {
286N/A prefix = "";
286N/A namespace = Constants.S_XSLNAMESPACEURL;
286N/A methName = fullName;
286N/A }
286N/A else
286N/A {
286N/A prefix = fullName.substring(0, indexOfNSSep);
286N/A namespace = xctxt.getNamespaceContext().getNamespaceForPrefix(prefix);
286N/A if (null == namespace)
286N/A return XBoolean.S_FALSE;
286N/A methName= fullName.substring(indexOfNSSep + 1);
286N/A }
286N/A
286N/A if (namespace.equals(Constants.S_XSLNAMESPACEURL)
286N/A || namespace.equals(Constants.S_BUILTIN_EXTENSIONS_URL)) {
286N/A
286N/A // J2SE does not support Xalan interpretive
286N/A /*
286N/A try {
286N/A TransformerImpl transformer = (TransformerImpl) xctxt.getOwnerObject();
286N/A return transformer.getStylesheet().getAvailableElements().containsKey(
286N/A new QName(namespace, methName))
286N/A ? XBoolean.S_TRUE : XBoolean.S_FALSE;
286N/A } catch (Exception e) {
286N/A return XBoolean.S_FALSE;
286N/A }
286N/A */
286N/A return XBoolean.S_FALSE;
286N/A } else {
286N/A //dml
286N/A ExtensionsProvider extProvider = (ExtensionsProvider)xctxt.getOwnerObject();
286N/A return extProvider.elementAvailable(namespace, methName)
286N/A ? XBoolean.S_TRUE : XBoolean.S_FALSE;
286N/A }
286N/A }
286N/A}