Altova Mailing List Archives


RE: [xsl] generic sort based on attribute names

From: "Michael Kay" <mike@------------>
To:
Date: 1/23/2005 11:29:00 PM
> > Here's a solution using the latter approach:
> > 
> > <xsl:for-each select="e">
> >  <xsl:sort>
> >    <xsl:for-each select="@*">
> >      <xsl:sort select="name()"/>
> >      <xsl:value-of select='name(), "=""", ., """ "' separator=""/>
> >    </xsl:for-each>
> >  </xsl:sort>
> >  <xsl:copy-of select="."/>
> > </xsl:for-each>
> > 
> Saxon 8.2 produces an error message that:
> 
> "A sequence of more than one item is not allowed as the @sort-key
> attribute of xsl:sort".

OK: you need to wrap it like this:

> > <xsl:for-each select="e">
> >  <xsl:sort>
      <xsl:value-of>
> >    <xsl:for-each select="@*">
> >      <xsl:sort select="name()"/>
> >      <xsl:value-of select='name(), "=""", ., """ "' separator=""/>
> >    </xsl:for-each>
      </xsl:value-of>
> >  </xsl:sort>
> >  <xsl:copy-of select="."/>
> > </xsl:for-each>
> 
> Besides this problem, does xsl:sort have a "sort-key" attribute? I
> don't see it specified either in the latest WG draft or in the book.
> 
Looks like the error message needs improving... 

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

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.