Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-2287

element-available failed for the extension which not actually used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.7
    • None
    • XPath-function
    • None

    Description

      The function element-available fails for the extension which is not actually used.
      Sometimes, it causes exception, and sometimes just returns false.

      Here's the stylesheet caused the problem:

      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:redirect="http://xml.apache.org/xalan/redirect"
      xmlns:xalanredirect="org.apache.xalan.xslt.extensions.Redirect"
      extension-element-prefixes="xalanredirect redirect"
      version="1.0">

      <xsl:template match="/">
      <xsl:message>
      <xsl:text>XSL Vendor: </xsl:text>
      <xsl:value-of select="system-property('xsl:vendor')"/>
      </xsl:message>

      <xsl:choose>
      <xsl:when test="element-available('xalanredirect:write')">
      <xsl:message>
      <xsl:text>xalanredirect:write available</xsl:text>
      <xalanredirect:write file="dummy1.xml"/> <!-- **** -->
      </xsl:message>
      </xsl:when>
      <xsl:otherwise>
      <xsl:message>
      <xsl:text>xalanredirect:write NOT available</xsl:text>
      </xsl:message>
      </xsl:otherwise>
      </xsl:choose>

      <xsl:choose>
      <xsl:when test="element-available('redirect:write')">
      <xsl:message>
      <xsl:text>redirect:write available</xsl:text>
      </xsl:message>
      <redirect:write file="dummy2.xml"/> <!-- **** -->
      </xsl:when>
      <xsl:otherwise>
      <xsl:message>
      <xsl:text>redirect:write NOT available</xsl:text>
      </xsl:message>
      </xsl:otherwise>
      </xsl:choose>

      </xsl:template>

      </xsl:stylesheet>

      Removing any one of the two lines indicated by <!-- **** -->, will cause
      the corresponding element-available test to return false. Here's the command line
      output:

      E:\xslt>SET CLASSPATH=E:\apache\xalan-j_2_7_0\serializer.jar;E:\apache\xalan-j_2
      _7_0\xalan.jar;E:\apache\xalan-j_2_7_0\xercesImpl.jar;E:\apache\xalan-j_2_7_0\xm
      l-apis.jar
      E:\xslt>java -Duser.language=en org.apache.xalan.xslt.Process -in index.xml -xsl
      style.xsl
      file:///E:/xslt/style.xsl; Line #10; Column #16; XSL Vendor: Apache Software Fou
      ndation
      file:///E:/xslt/style.xsl; Line #17; Column #20; xalanredirect:write available
      file:///E:/xslt/style.xsl; Line #36; Column #20; redirect:write NOT available
      <?xml version="1.0" encoding="UTF-8"?>

      If both lines are removed, transforming will fail:

      E:\xslt>SET CLASSPATH=E:\apache\xalan-j_2_7_0\serializer.jar;E:\apache\xalan-j_2
      _7_0\xalan.jar;E:\apache\xalan-j_2_7_0\xercesImpl.jar;E:\apache\xalan-j_2_7_0\xm
      l-apis.jar
      E:\xslt>java -Duser.language=en org.apache.xalan.xslt.Process -in index.xml -xsl
      style.xsl
      file:///E:/xslt/style.xsl; Line #10; Column #16; XSL Vendor: Apache Software Fou
      ndation
      file:///E:/xslt/style.xsl; Line #16; Column #63; XSLT Error (javax.xml.transform
      .TransformerException): Unknown error in XPath.
      Exception in thread "main" java.lang.RuntimeException: Unknown error in XPath.
      at org.apache.xalan.xslt.Process.doExit(Process.java:1153)
      at org.apache.xalan.xslt.Process.main(Process.java:1126)

      Attachments

        Activity

          People

            Unassigned Unassigned
            stephensuen Stephen Suen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: