Hi Renick,
I don't have that Xalan version, so I can't test your findings, but I
can tell almost for sure that the output reveals a bug. You have a line
<xsl:apply-templates select="$theData/grp">
which is only called once. It selects two nodes. In no way can it select
two nodes twice and certainly that has nothing to do with whether or not
you pass in a literal value (I am quite surprised it actually changes
your output!). You should post this to the Xalan team, I suppose.
I looked a bit through your stylesheet and I saw you use quite a lot of
unnecessary redundancies. I.e., omit-xml-declaration only does something
with output method XML, the $grpData is not needed because all you need
to select are children of the current node and the variable $gid is
redundant, you can just as well use the @gid directly in the AVT. And
the call-template is neither needed because you are only processing
children of the current node (with the code you showed, the $theData
would always select all nodes with that absolute path and may result in
duplicated output depending on the rest of your input structure, if you
don't want that, use this new approach). Here's a bit shorter version.
Perhaps it works more stable in Xalan too?
(maybe you just changed the code the way it was to illustrate a point,
in which way you can ignore the above comment of course)
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" />
<xsl:template match="/document">
<xsl:apply-templates select="*" />
</xsl:template>
<xsl:template match="permission">
<select name="selectName" size="{count(grp)}" multiple="true">
<xsl:apply-templates select="grp">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</select>
</xsl:template>
<xsl:template match="grp">
<option value="{(_at_)gid}"><xsl:value-of select="@name"/></option>
</xsl:template>
</xsl:stylesheet>
Cheers,
-- Abel Braaksma
Renick, Garrel wrote:
I have an odd problem that seems unexplainable. I'm seeing different
results of a simple transformation using xalan-j_2_6_0 (and prior
versions) versus xalan-j_2_7_0. The xalan-j_2_7_0 version results in
duplicated output. I'm using jdk1.5.0_12. Here are examples:
XML:
<?xml version='1.0'?>
<document>
<permission>
<grp gid="101" name="group1"/>
<grp gid="102" name="group2"/>
</permission>
</document>
XSLT:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:variable name="theData" select="/document/permission"/>
<xsl:template match="/document">
<xsl:variable name="grpcount" select="count($theData/grp)"/>
<xsl:call-template name="makeGroupList">
<xsl:with-param name="groupSize" select="$grpcount"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="makeGroupList">
<xsl:param name="groupSize"/>
<select name="selectName" size="{$groupSize}" multiple="true">
<xsl:apply-templates select="$theData/grp">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</select>
</xsl:template>
<xsl:template match="grp">
<xsl:variable name="gid" select="./@gid"/>
<option value="{$gid}"><xsl:value-of select="@name"/></option>
</xsl:template>
</xsl:stylesheet>
Output xalan-j_2_7_0:
<select multiple="true" size="2" name="selectName">
<option value="101">group1</option>
<option value="101">group1</option>
<option value="102">group2</option>
<option value="102">group2</option>
</select>
However, the output from j_2_6_0 is as expected:
Output xalan-j_2_6_0:
<select multiple="true" size="2" name="selectName">
<option value="101">group1</option>
<option value="102">group2</option>
</select>
If I comment out the grpcount variable definition and pass a param with
a literal value in the call to the makeGroupList template, both versions
of xalan produce the same output.
I'd appreciate any insight into why this is happening.
Regards,
Garrel Renick
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--