Subject: Re: [xsl] How to save the sorted nodes in a variable and parse it From: John Robb <john_ok@xxxxxx> Date: Mon, 25 Jul 2005 18:36:06 +0300 |
In this:
<xsl:variable name="sItem" select="ms:node-set($sorted)"/> <xsl:for-each select="$sItem"> <div> <xsl:value-of select="."/> </div> </xsl:for-each>
$sItem is a single document node. You want to address within it, something
like <xsl:for-each select="$sItem/*">. Do an xsl:copy-of select="$sItem" for
diagnostics to check what's in your variable.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: John Robb [mailto:john_ok@xxxxxx] Sent: 25 July 2005 15:59
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] How to save the sorted nodes in a variable and parse it
How is it posssible to save sorted elements in a variable and in the other template to parse it.Something like that $var/element...
I am using the following xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:schemas-microsoft-com:xslt">
<xsl:output media-type="xml"/>
<xsl:variable name="sorted">
<xsl:apply-templates mode="copy" select="data"/>
</xsl:variable>
<xsl:template match="@*|node()" mode="copy">
<xsl:copy>
<xsl:apply-templates select="@*|node()">
<xsl:sort select="@sector"/>
<xsl:sort select="@subsector"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="/" mode="main">
<xsl:variable name="sItem" select="ms:node-set($sorted)"/>
<xsl:for-each select="$sItem">
<div>
<xsl:value-of select="."/>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
But the part where I want to output the results:
<xsl:variable name="sItem" select="ms:node-set($sorted)"/>
<xsl:for-each select="$sItem">
<div>
<xsl:value-of select="."/>
</div>
</xsl:for-each>
performs only once.And the value of the $sItem variable is just values of all the elements from the input xml.
The xml is:
<?xml version="1.0" encoding="iso-8859-1" ?> <data> <item id="i1" sector="s1" subsector="u1">561</item> <item id="i10" sector="s3" subsector="u4">15</item> <item id="i22" sector="s2" subsector="u2">1234</item> <item id="i11" sector="s1" subsector="u2">123</item> <item id="i17" sector="s1" subsector="u3">165</item> <item id="i61" sector="s2" subsector="u1">346</item> <item id="i12" sector="s2" subsector="u5">3425</item> <item id="i2" sector="s3" subsector="u4">78</item> <item id="i14" sector="s3" subsector="u4">51</item> <item id="i21" sector="s1" subsector="u5">346</item> <item id="i39" sector="s3" subsector="u2">463</item> <item id="i44" sector="s2" subsector="u3">151</item> <item id="i89" sector="s1" subsector="u1">451</item> <item id="i81" sector="s2" subsector="u4">771</item> <item id="i36" sector="s2" subsector="u5">5654</item> <item id="i27" sector="s3" subsector="u3">362</item> <item id="i15" sector="s1" subsector="u5">234</item> <item id="i18" sector="s3" subsector="u2">73</item> <item id="i51" sector="s3" subsector="u5">567</item> <item id="i26" sector="s1" subsector="u4">17</item> <item id="i95" sector="s3" subsector="u5">67489</item> <item id="i13" sector="s1" subsector="u3">54</item> <item id="i71" sector="s1" subsector="u3">2</item> <item id="i23" sector="s2" subsector="u1">345</item> <item id="i7" sector="s2" subsector="u1">67</item> <item id="i80" sector="s1" subsector="u3">7754</item> <item id="i9" sector="s3" subsector="u4">343</item>
<sector id="s1">Sector 1</sector> <sector id="s2">Sector 2</sector> <sector id="s3">Sector 3</sector>
<subsector id="u1">Subsector 1</subsector>
<subsector id="u2">Subsector 2</subsector>
<subsector id="u3">Subsector 3</subsector>
<subsector id="u4">Subsector 4</subsector>
<subsector id="u5">Subsector 5</subsector>
</data>
---
GSM.By.COM - hmrepmer-l`c`ghm qnrnb{u reketnmnb qr`md`pr` GSM,
`jqeqqs`pnb h g`ow`qrei j mhl. Xhpnjhi b{anp, p`gslm{e vem{,
noep`rhbm` dnqr`bj`. Pelnmr reketnmnb. http://www.gsm.by.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to save the sorted no, Michael Kay | Thread | RE: [xsl] RE: Unterminated String C, Dan Powderhill |
RE: [xsl] Keys working on nodeset?, Joe Fawcett | Date | RE: [xsl] RE: Unterminated String C, Dan Powderhill |
Month |