|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Generating a list of items NOT present in source X
At 11:57 AM 5/17/2002, you wrote:
<xsl:with-param name="count" select="count + 1" />
Jeni, I modified your code to the following stylesheet. The first template matches / and calls the other template with a sorted node-set. I have a question at the end of the sheet. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" extension-element-prefixes="msxsl"> <xsl:output method="html" indent="yes"/> <xsl:template match="/"> <missing> <xsl:variable name="sorted-obj-rtf"> <xsl:for-each select="root/obj"> <xsl:sort data-type="number" select="childnode"/> <xsl:copy-of select="."/> </xsl:for-each> </xsl:variable> <xsl:call-template name="show-missing"> <xsl:with-param name="nodes" select="msxsl:node-set($sorted-obj-rtf)/obj"/> <xsl:with-param name="start-number" select="1"/> <xsl:with-param name="end-number" select="9"/> <xsl:with-param name="index" select="'./childnode'"/> </xsl:call-template> </missing> </xsl:template> <!-- Named Template "show-missing" -->
<xsl:template name="show-missing">
<xsl:param name="nodes" select="/.."/>
<xsl:param name="start-number" select="1"/>
<xsl:param name="end-number" select="1"/>
<xsl:param name="index"/>
<xsl:if test="$nodes and $index and ($end-number >= $start-number)">
<xsl:choose>
<!-- For each of these tests, instead of comparing against
$nodes[1], I would like to compare against
$nodes[1]/($index converted to XPath path)/. -->
<xsl:when test="$start-number > $nodes[1]">
<xsl:call-template name="show-missing">
<xsl:with-param name="nodes" select="$nodes[position() > 1]"/>
<xsl:with-param name="start-number" select="$start-number"/>
<xsl:with-param name="end-number" select="$end-number"/>
<xsl:with-param name="index" select="$index"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$start-number = $nodes[1]">
<xsl:call-template name="show-missing">
<xsl:with-param name="nodes" select="$nodes[position() > 1]"/>
<xsl:with-param name="start-number" select="$start-number + 1"/>
<xsl:with-param name="end-number" select="$end-number"/>
<xsl:with-param name="index" select="$index"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<obj>
<childnode>
<xsl:value-of select="$start-number"/>
</childnode>
</obj>
<xsl:call-template name="show-missing">
<xsl:with-param name="nodes" select="$nodes"/>
<xsl:with-param name="start-number" select="$start-number + 1"/>
<xsl:with-param name="end-number" select="$end-number"/>
<xsl:with-param name="index" select="$index"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>The above works for the simple XML document given in the previous post because the string() of the obj node is the same as the string() of the only contained obj/childnode node. What is the best way (or is there a way) to allow $index to be converted from a string to the XPath that the string represents?
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








