Issue Details (XML | Word | Printable)

Key: XALANJ-1928
Type: Bug Bug
Status: Reopened Reopened
Priority: Major Major
Assignee: Unassigned
Reporter: Barys Dubauski
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XalanJ2

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

Created: 20/Aug/04 04:42 AM   Updated: 10/Aug/05 03:40 PM
Return to search
Component/s: XSLTC
Affects Version/s: 2.7.1
Fix Version/s: None
Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)

Time Tracking:
Not Specified

File Attachments:
  Size
Zip Archive Licensed for inclusion in ASF works test.zip 2005-02-11 01:33 AM David Green 1 kB
Environment:
Operating System: Other
Platform: Other


 Description  « Hide
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 !<key>!.
       
       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>

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Serge Knystautas made changes - 02/Sep/04 10:10 PM
Field Original Value New Value
issue.field.bugzillaimportkey 30766 26837
Henry Zongaro made changes - 04/Oct/04 04:04 PM
Status Open [ 1 ] Resolved [ 5 ]
Assignee Xalan Developers Mailing List [ xalan-dev@xml.apache.org ]
Resolution Cannot Reproduce [ 5 ]
Henry Zongaro made changes - 11/Feb/05 12:53 AM
Status Resolved [ 5 ] Reopened [ 4 ]
Resolution Cannot Reproduce [ 5 ]
David Green made changes - 11/Feb/05 01:33 AM
Attachment test.zip [ 18923 ]
Henry Zongaro made changes - 01/Mar/05 06:41 AM
Bugzilla Id 30766
Environment Operating System: Other
Platform: Other
Operating System: Other
Platform: Other
Priority Major [ 3 ]
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 !<key>!.
       
       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>
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 !<key>!.
       
       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>
Brian Minchau made changes - 10/Aug/05 03:40 PM
Affects Version/s 2.6 [ 10871 ]
Affects Version/s Latest Development Code [ 10863 ]