Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] Problems sorting data

From: "Michael Kay" <mike@------------>
To:
Date: 7/4/2005 2:42:00 PM
I'm shocked that any XSLT processor should accept the nested templates
without complaint.

You want:


<xsl:template match="contents">
 	<xsl:apply-templates select="object">
 		<xsl:sort select="member[@name='idstring']/string"/>
 	</xsl:apply-templates>
 	</xsl:template>


Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Glenn Thomas Hvidsten [mailto:gth@xxxxxxxxx] 
> Sent: 04 July 2005 14:25
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Problems sorting data
> 
> Hi,
> 
> I've created the XML below and now I need to present the data in an 
> orderly fashion. More precisely I need to have the data sorted by the 
> 'idstring' member. I've done some googling and this is the 
> best I could 
> come up with, but the data is still not sorted. The data is 
> presented, 
> though, so obviously I'm doing something right.
> What is wrong with this sorting and what can I do to fix it?
> 
> 
> XSLT:
> 
> <xsl:template match="report">
> 
> 	<xsl:template match="contents">
> 	<xsl:apply-templates>
> 		<xsl:sort select="member[@name='idstring']"/>
> 	</xsl:apply-templates>
> 	</xsl:template>
> 
> </xsl:template>
> 
> <xsl:template match="object[@type='standard']">
> 	<xsl:value-of select="member[@name='idstring']"/>
> 	<xsl:value-of select="member[@name='id']"/>
> 	<xsl:value-of select="member[@name='title']"/>
> </xsl:template>
> 
> 
> 
> XML:
> 
> <report>
> <contents>
> 
> 	<object type="standard">
> 		<member name="id">
> 			<long>1234</long>
> 		</member>
> 		<member name="idstring">
> 			<string>Unique1</string>
> 		</member>
> 		<member name="title">
> 			<string>Temporary</string>
> 		</member>
> 	</object>
> 
> 	<object type="standard">
> 		<member name="id">
> 			<long>5678</long>
> 		</member>
> 		<member name="idstring">
> 			<string>Unique2</string>
> 		</member>
> 		<member name="title">
> 			<string>Foobar</string>
> 		</member>
> 	</object>
> 
> </contents>
> </report>
> 
> 
> -- 
> 
> Glenn Thomas Hvidsten
> 
> =============  CORENA Norge AS  =============
> == Dyrmyrgt. 35, N-3611 Kongsberg, NORWAY  ==
> == Tlf: +47 3271 7234, Fax: +47 3271 7201  ==
> == CORENA Home Page: http://www.corena.com ==
> =============================================


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent