> does anyone have the solution to the following problem?
>
> -how does one sort by attribute values? Iv'e tried with script function
> sort(), but it doesn't work (returns error message "sortField is null or not
> an object".
>
> example:
>
> <row time="2001-03-26 15:53:35:98" type="4" sev="E">comments not to be
> sorted</row>
> .
> .
> <row time=" ...................>
>
> Thanx
>
> jB
E.g., to sort <row>s by their 'time' attribute, this works:
<xsl:template match="parent-of-row">
<xsl:apply-templates select="row">
<xsl:sort select="@time">
</xsl:apply-templates>
</xsl:template>
Have fun,
Paul Tyson
> Thanx Paul!
>
> Still one problem remains. How do I sort dynamically. My code consists of an
> XML-page and a XSL stylesheet. The stylesheet contains the HTML-code, which
> displays the content of the XML-source. The row attributes are columned
> under headers like "timestamp", "type" etc. Under these headers the
> attribute values are listed. I would like to make a code that gives the user
> capability of sorting these values by clicking on the headers, somthing like
> onclick="sort('@time')". Has anyone got the answer?
>
> Thank you in advance
>
To parameterize the name of the attribute value for sorting, you can
do something like this:
<xsl:param name="sort-key-att-name" select="'time'"/>
<xsl:template match="table">
<xsl:apply-templates select="row">
<xsl:sort select="@*[local-name()=$sort-key-att-name]"/>
</xsl:apply-templates>
</xsl:template>
When you invoke the transformation, pass it the 'sort-key-att-name'
parameter value (which should be one of the attribute names on <row>).
Cheers,
Paul Tyson
> jb
> <pa...@my.ptlinux.org> wrote in message news:87y9trv...@my.ptlinux.org...