|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSL to Sort XML Doc return XML
Hi Xiaocun and xsl-list, I am a novice and thought I would try your solution for myself. I had to wrap up your xsl a little bit and have produced the following two flavours of code that work (one with for-each, the other with apply-templates). for-each flavour: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="/"> <records> <xsl:for-each select="records/record"> <xsl:sort select="."/> <record><xsl:value-of select="."/></record> </xsl:for-each> </records> </xsl:template> </xsl:stylesheet> apply-templates flavour: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="records"> <records><xsl:apply-templates><xsl:sort select="."/></xsl:apply-templates></records> </xsl:template> <xsl:template match="record"> <record><xsl:value-of select="."/></record> </xsl:template> </xsl:stylesheet> I am at a bit of loss as to which approach would be better (and I don't even know how to name these two approaches). Can you recommend a reference/web tutorial/whatever that will help me better understand the design patterns being used and when to use which? Thanks, J. > From: Xiaocun Xu [mailto:xiaocunxu@xxxxxxxxx] > Sent: Thursday, May 31, 2001 2:49 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: XSL to Sort XML Doc return XML > Doc ? > > Hi, Matt: > > This can be done pretty easily with xsl:sort, > like: > <records> > <xsl:for-each select="records/record"> > <xsl:sort select="."/> > <record><xsl:value-of select="."/></record> > </xsl:for-each> > </records> James MacEwan Software Developer Investors Group Inc. mailto:James.MacEwan@xxxxxxxxxxxxxxxxxx v: (204) 956-8515 f: (204) 943-3540 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








