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

XSLTC fails to access auxilliary (non-main) xml file.

    Details

    • Type: Bug
    • Status: Reopened
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.7.1
    • Fix Version/s: None
    • Component/s: XSLTC
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • Labels:
      None
    • Environment:
      Operating System: Other
      Platform: Other

      Description

      In our project we need to access non-main XML file in order to retrieve
      localized strings that will later appear in resulting HTMLs. If we use XSLTC
      as our processor it is impossible.

      Example. The same example works fine in interpretive Xalan. But fails on Xalan-
      XSLTC.

      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
      xmlns:xalan="http://xml.apache.org/xalan">

      <xsl:output method="html"/>

      <xsl:variable name="stringTable" select="document('foo.xml')"/>

      <!-- Look up the parameter key in the localized string table (loaded in
      the variable stringTable
      based on the passed in parameter stringTableFileName). If the key
      cannot be found then the
      returned string will be Unable to render embedded object: File (<key>) not found..

      Parameters:
      key - the look up key matched to the key attribute of string elements
      in the lookup table
      -->

      <!-- Perhaps not the fastest approach but it is compatible with both XSLTC
      and interpretive Xalan -->
      <xsl:template name="getLocalizedString">
      <xsl:param name="key"/>
      <xsl:value-of select="$key"/>
      <xsl:variable name="lookupString" select="$stringTable/strings/string
      [@key=$key]"/>
      <xsl:choose>
      <xsl:when test="$lookupString != ''">
      <xsl:value-of select="$lookupString"/>
      </xsl:when>
      <xsl:otherwise>
      <xsl:element name="a">
      <xsl:attribute name="name">MISSING_L10N_KEY</xsl:attribute>
      <xsl:text>!!</xsl:text>
      <xsl:value-of select="$key"/>
      <xsl:text>!!</xsl:text>
      </xsl:element>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:template>
      </xsl:stylesheet>

      Example of XML file

      <?xml version="1.0" encoding="UTF-8" ?>
      <strings>
      <string key="Description.Foo">Here goes description of foo</string>
      </strings>

      1. test.zip
        1 kB
        David Green

        Activity

        Hide
        bdubausk@us.ibm.com Barys Dubauski added a comment -

        Please disregard the comments in the examples I put in the description. They
        are old and not true.

        Show
        bdubausk@us.ibm.com Barys Dubauski added a comment - Please disregard the comments in the examples I put in the description. They are old and not true.
        Hide
        zongaro@ca.ibm.com Henry Zongaro added a comment -

        I added the following template to your example stylesheet to make it complete.
        When I did so, the example worked with both Xalan-J Interpretive and XSLTC.

        <xsl:template match="/">
        <xsl:call-template name="getLocalizedString">
        <xsl:with-param name="key" select="'Description.Foo'"/>
        </xsl:call-template>
        </xsl:template>

        May I ask you to provide a complete example that demonstrates the problem you
        are encountering, along with specific details about the failure that you see
        with XSLTC?

        Show
        zongaro@ca.ibm.com Henry Zongaro added a comment - I added the following template to your example stylesheet to make it complete. When I did so, the example worked with both Xalan-J Interpretive and XSLTC. <xsl:template match="/"> <xsl:call-template name="getLocalizedString"> <xsl:with-param name="key" select="'Description.Foo'"/> </xsl:call-template> </xsl:template> May I ask you to provide a complete example that demonstrates the problem you are encountering, along with specific details about the failure that you see with XSLTC?
        Hide
        zongaro@ca.ibm.com Henry Zongaro added a comment -

        I was unable to reproduce this problem given the information provided. If you are still able to reproduce it, please reopen the bug report, attaching a complete sample stylesheet and complete sample input.

        Show
        zongaro@ca.ibm.com Henry Zongaro added a comment - I was unable to reproduce this problem given the information provided. If you are still able to reproduce it, please reopen the bug report, attaching a complete sample stylesheet and complete sample input.
        Hide
        zongaro@ca.ibm.com Henry Zongaro added a comment -

        Based on the test case David Green attached to the original Bugzilla bug report, this might be a duplicate of XALANJ-1348.

        Show
        zongaro@ca.ibm.com Henry Zongaro added a comment - Based on the test case David Green attached to the original Bugzilla bug report, this might be a duplicate of XALANJ-1348 .
        Hide
        dgreen99 David Green added a comment -

        A test case with two XML documents, an XSL stylesheet and an Ant build script to run the test case.

        Show
        dgreen99 David Green added a comment - A test case with two XML documents, an XSL stylesheet and an Ant build script to run the test case.
        Hide
        dgreen99 David Green added a comment -

        This case reproduces the problem: ( I accidentally posted this against XALANJ-1348 as well)

        !DOCUMENT1 (foo.xml)
        <?xml version="1.0" encoding="UTF-8"?>
        <foo>
        <a>foo</a>
        </foo>

        !DOCUMENT2 (bar.xml)
        <?xml version="1.0" encoding="UTF-8"?>
        <bar>
        <b>bar</b>
        </bar>

        !XSLT Stylesheet
        <?xml version="1.0" encoding="UTF-8"?>
        <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

        <xsl:variable name="BAR" select="document('bar.xml',/)"/>

        <xsl:template match="/">
        <xsl:message>
        Foo root element name: <xsl:value-of select="local-name(/*)"/>
        </xsl:message>
        <xsl:for-each select="$BAR/bar/b">
        <xsl:message>
        Bar root element name: <xsl:value-of select="local-name(/*)"/>
        </xsl:message>
        </xsl:for-each>
        </xsl:template>
        </xsl:stylesheet>

        The output of running the test (from Ant) is as follows:

        foobar-test:
        [echo]
        [echo] USING XSLTC PROCESSOR
        [echo]

        [java] Foo root element name: foo

        [java] Bar root element name: foo

        [java] <?xml version="1.0" encoding="UTF-8"?>
        [echo]
        [echo] USING INTERPRETIVE PROCESSOR
        [echo]
        [java] file:///C:/dev/BCCampus/connector/server-system/codegen/foobar.xslt;
        Line #8; Column #19;
        [java] Foo root element name: foo
        [java] file:///C:/dev/BCCampus/connector/server-system/codegen/foobar.xslt;
        Line #12; Column #19;
        [java] Bar root element name: bar

        [java] <?xml version="1.0" encoding="UTF-8"?>

        Show
        dgreen99 David Green added a comment - This case reproduces the problem: ( I accidentally posted this against XALANJ-1348 as well) !DOCUMENT1 (foo.xml) <?xml version="1.0" encoding="UTF-8"?> <foo> <a>foo</a> </foo> !DOCUMENT2 (bar.xml) <?xml version="1.0" encoding="UTF-8"?> <bar> <b>bar</b> </bar> !XSLT Stylesheet <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:variable name="BAR" select="document('bar.xml',/)"/> <xsl:template match="/"> <xsl:message> Foo root element name: <xsl:value-of select="local-name(/*)"/> </xsl:message> <xsl:for-each select="$BAR/bar/b"> <xsl:message> Bar root element name: <xsl:value-of select="local-name(/*)"/> </xsl:message> </xsl:for-each> </xsl:template> </xsl:stylesheet> The output of running the test (from Ant) is as follows: foobar-test: [echo] [echo] USING XSLTC PROCESSOR [echo] [java] Foo root element name: foo [java] Bar root element name: foo [java] <?xml version="1.0" encoding="UTF-8"?> [echo] [echo] USING INTERPRETIVE PROCESSOR [echo] [java] file:///C:/dev/BCCampus/connector/server-system/codegen/foobar.xslt ; Line #8; Column #19; [java] Foo root element name: foo [java] file:///C:/dev/BCCampus/connector/server-system/codegen/foobar.xslt ; Line #12; Column #19; [java] Bar root element name: bar [java] <?xml version="1.0" encoding="UTF-8"?>
        Hide
        santiago.pericasgeertsen@sun.com Santiago Pericas-Geertsen added a comment -

        I have verified that the problem still exists with the current CVS. Henry: Do you want to take this one?

        Show
        santiago.pericasgeertsen@sun.com Santiago Pericas-Geertsen added a comment - I have verified that the problem still exists with the current CVS. Henry: Do you want to take this one?
        Hide
        zongaro@ca.ibm.com Henry Zongaro added a comment -

        Priority was lost in move from Bugzilla.

        Show
        zongaro@ca.ibm.com Henry Zongaro added a comment - Priority was lost in move from Bugzilla.

          People

          • Assignee:
            Unassigned
            Reporter:
            bdubausk@us.ibm.com Barys Dubauski
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development