Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - XSL output of complete element >Thread Next - Re: XSL output of complete element Re: XSL output of complete elementTo: NULL Date: 7/2/2008 1:58:00 AM On Jul 2, 2:38=A0am, sbparsons <sbpars...@discussions.microsoft.com> wrote: > Please can someone give me a sample xsl to output a complete element in a > for-each loop? > For example I'd like to sort the output on <level> by the <sort> value, bu= t > as you can see, the elements underneath the <level> node may vary : > <root> > =A0 <level> > =A0 =A0 <sort>2</sort> > =A0 =A0 <x></x> > =A0 =A0 <y></y> > =A0 </level> > =A0 <level> > =A0 =A0 <sort>1</sort> > =A0 =A0 <x></x> > =A0 =A0 <a></a> > =A0 </level> > =A0 <level> > =A0 =A0 <sort>3</sort> > =A0 =A0 <c></c> > =A0 =A0 <d></d> > =A0 =A0 <e></e> > =A0 </level> > </root> > > Expected output: > <root> > =A0 <level> > =A0 =A0 <sort>1</sort> > =A0 =A0 <x></x> > =A0 =A0 <a></a> > =A0 </level> > =A0 <level> > =A0 =A0 <sort>2</sort> > =A0 =A0 <x></x> > =A0 =A0 <y></y> > =A0 </level> > =A0 <level> > =A0 =A0 <sort>3</sort> > =A0 =A0 <c></c> > =A0 =A0 <d></d> > =A0 =A0 <e></e> > =A0 </level> > </root> > > Thanks - I'm sure it's a doddle for someone here. Hi, <xsl:stylesheet version=3D"1.0" xmlns:xsl=3D"http://www.w3.org/1999/XSL/ Transform"> <xsl:template match=3D"root"> <xsl:copy> <xsl:for-each select=3D"level"> <xsl:sort select=3D"sort" data-type=3D"number"/> <xsl:copy-of select=3D"."/> </xsl:for-each> </xsl:copy> </xsl:template> </xsl:stylesheet> Regards, Balaji. M sql-ebooks.blogspot.com | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
