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. import com.sun.org.apache.xalan.internal.templates.Constants;
  18. //import com.sun.org.apache.xalan.internal.transformer.TransformerImpl;
  19. import com.sun.org.apache.xml.internal.utils.QName;
  20. import com.sun.org.apache.xpath.internal.ExtensionsProvider;
  21. import com.sun.org.apache.xpath.internal.XPathContext;
  22. import com.sun.org.apache.xpath.internal.objects.XBoolean;
  23. import com.sun.org.apache.xpath.internal.objects.XObject;
  24. /**
  25. * Execute the ExtElementAvailable() function.
  26. * @xsl.usage advanced
  27. */
  28. public class FuncExtElementAvailable extends FunctionOneArg
  29. {
  30. /**
  31. * Execute the function. The function must return
  32. * a valid object.
  33. * @param xctxt The current execution context.
  34. * @return A valid XObject.
  35. *
  36. * @throws javax.xml.transform.TransformerException
  37. */
  38. public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
  39. {
  40. String prefix;
  41. String namespace;
  42. String methName;
  43. String fullName = m_arg0.execute(xctxt).str();
  44. int indexOfNSSep = fullName.indexOf(':');
  45. if (indexOfNSSep < 0)
  46. {
  47. prefix = "";
  48. namespace = Constants.S_XSLNAMESPACEURL;
  49. methName = fullName;
  50. }
  51. else
  52. {
  53. prefix = fullName.substring(0, indexOfNSSep);
  54. namespace = xctxt.getNamespaceContext().getNamespaceForPrefix(prefix);
  55. if (null == namespace)
  56. return XBoolean.S_FALSE;
  57. methName= fullName.substring(indexOfNSSep + 1);
  58. }
  59. if (namespace.equals(Constants.S_XSLNAMESPACEURL)
  60. || namespace.equals(Constants.S_BUILTIN_EXTENSIONS_URL))
  61. {
  62. // <<<<<<< TIGER SPECIFIC CHANGE >>>>>>>>>
  63. // As we are not supporting Xalan interpretive we are taking away the functionality
  64. // dependent on XSLT interpretive Transformer. Only way supported is to use XSLTC
  65. // and the execution path needed for supporting standard XPath API defined by
  66. // JAXP 1.3 . This method is overridden in XPath implementation to support
  67. // standard XPath functionality with xpath package of Xalan
  68. return XBoolean.S_FALSE;
  69. }
  70. else
  71. {
  72. //dml
  73. ExtensionsProvider extProvider = (ExtensionsProvider)xctxt.getOwnerObject();
  74. return extProvider.elementAvailable(namespace, methName)
  75. ? XBoolean.S_TRUE : XBoolean.S_FALSE;
  76. }
  77. }
  78. }