Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: XSL + XML => sort nodes by ids [Thread Next] Re: XSL + XML => sort nodes by idsTo: NULL Date: 5/10/2009 7:38:00 PM "Martin Honnen" <mahotrash@y...> a écrit dans le message de news:Od%23fsBZ0JHA.5744@T...... > Nicopil@mi wrote: >> Hi everybody, i would like to sort alphabetically the "rep" items by >> their id parameter. >> Could you help me to make the xsl file please ? >> >> <repertoires> >> <rep id=nomdurep1> >> <param .... /> >> <param .... /> >> </rep> >> <rep id=nomdurep2> >> <param .... /> >> <param .... /> >> </rep> >> <rep id=nomdurep3> >> <rep id=nomdusousrep1> >> <param .... /> >> <param .... /> >> </rep> >> <rep id=nomdusousrep2> >> <param .... /> >> <param .... /> >> </rep> >> <param .... /> >> <param .... /> >> </rep> >> </repertoires> > > Consider to post well-formed snippets of XML, otherwise we can't test our > solutions against your sample data. > So here is some untested suggestion: > > <xsl:template match="reportoires"> > <xsl:copy> > <xsl:apply-templates select="rep"> > <xsl:sort select="@id"/> > </xsl:apply-templates/> > </xsl:copy> > </xsl:template> > > <xsl:template match="rep"> > <xsl:copy> > <xsl:copy-of select="@*"/> > <xsl:apply-templates select="rep"> > <xsl:sort select="@id"/> > </xsl:apply-templates/> > <xsl:copy-of select="param"/> > </xsl:copy> > </xsl:template> > > That solution assumes you want to sort the 'rep' children of the > 'repertoires' element by their 'id' attribute value and then assumes that > you want sort the 'rep' children of each 'rep' element again by their 'id' > attribute value. > > You haven't really explained what you want to to with the nested 'rep' > elements so the above is just an assumption of what you might want. > > -- > > Martin Honnen --- MVP XML > http://msmvps.com/blogs/martin_honnen/ exactly what i needed !!! thank you very very very much bye Nico | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
