[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to save the sorted nodes in a variable and par

Subject: Re: 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
xmlns ms
I've corrected the xsl but the result is the same.In this place(<xsl:apply-templates select="ms:node-set($sorted)" ) I see just values of all elements:
<?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="/">
<xsl:apply-templates select="ms:node-set($sorted)" mode="main"/>
</xsl:template>
</xsl:stylesheet>




Mon, 25 Jul 2005 16:22:09 +0100, "Michael Kay" <mike@xxxxxxxxxxxx> ohq`k(`):

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: 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


---
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.