This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
DSSSL->XSLT; problems implementing node-list-first/node-list-rest
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] DSSSL->XSLT; problems implementing node-list-first/node-list-rest
- From: AKillian at wiley dot co dot uk
- Date: Mon, 26 Mar 2001 20:22:02 +0100
- Cc: akillian at wiley dot co dot uk
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi,
I am trying to translate a complex piece of DSSSL to XSLT and I need
to implement
the equivalent of: node-list-first/node-list-rest to use recursive
'xsl:call-template's.
I cannot get the following piece of test code (james's sort-uniq.xsl
butchered to use
a recursive node list processor) to work with either XT or Saxon (6.0.2):
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon"
version="1.0">
<xsl:template match="list">
<xsl:variable name="sorted">
<xsl:for-each select="item">
<xsl:sort/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
<html><body><ul>
<xsl:call-template name="proc-nl">
<xsl:with-param name="nl" select="$sorted"/>
</xsl:call-template>
</ul></body></html>
</xsl:template>
<xsl:template match="item">
<li><xsl:apply-templates/></li>
</xsl:template>
<xsl:template name="proc-nl">
<xsl:param name="nl"/>
<called>
<xsl:for-each select="saxon:nodeSet($nl)">
<xsl:message>
<xsl:copy-of select="."/>
</xsl:message>
</xsl:for-each>
</called>
<xsl:if test="string-length($nl) != 0">
<xsl:apply-templates select="saxon:nodeSet($nl)/*[1]"/>
<foo>bar</foo>
<xsl:call-template name="proc-nl">
<with-param name="nl" select="saxon:nodeSet($nl)/*[position()!='1']"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
This is the output. As you can see, instead of 'node-list-rest', nothing is being passed
to the recursive call to 'proc-nl'. I have passing the whole $nl, the first item, a simple string, but
nothing is getting through. Also, if I replace the <xsl:apply-templates> with a call to a different
template, it didn't get the first node either. I am perplexed.
aidan@development 314> java com.icl.saxon.StyleSheet sort-uniq.xml aidan_test_saxon.xsl
<html xmlns:saxon="http://icl.com/saxon">
<body>
<ul>
<called>
<item>A</item>
<item>A</item>
<item>A</item>
<item>A</item>
<item>A</item>
<item>A</item>
<item>B</item>
<item>C</item>
<item>C</item>
<item>D</item>
<item>D</item>
<item>E</item>
</called>
<li>A</li>
<foo>bar</foo>
<called></called>
</ul>
</body>
</html>aidan@development 315>
This is the source:
</html>aidan@development 315> more sort-uniq.xml
<list>
<item>D</item>
<item>D</item>
<item>A</item>
<item>A</item>
<item>B</item>
<item>A</item>
<item>A</item>
<item>C</item>
<item>C</item>
<item>A</item>
<item>A</item>
<item>E</item>
</list>
aidan@development 316>
Any help appreciated,
Aidan Killian
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list