Re: [xsl] Newbie question on XSL transformations: multiple sorts on element attributes

Subject: Re: [xsl] Newbie question on XSL transformations: multiple sorts on element attributes
From: Rob Newman <rlnewman@xxxxxxxx>
Date: Wed, 7 Feb 2007 08:08:52 -0800
Thanks for the help Owen and Abel.

I copied and pasted Owen's code into a new XSL file and tried to run it and again got a seg-fault:

{hostname}123%> xsltproc -v -o output.xml transform.xsl input.xml
creating dictionary for stylesheet
reusing dictionary from transform.xsl for stylesheet
Added namespace: xsl mapped to http://www.w3.org/1999/XSL/Transform
Segmentation fault

Checking the version of xsltproc results in:

{hostname} 124%> xsltproc -V
Using libxml 20627, libxslt 10109 and libexslt 807
xsltproc was compiled against libxml 20612, libxslt 10109 and libexslt 807
libxslt 10109 was compiled against libxml 20612
libexslt 807 was compiled against libxml 20612


Am I using an out-of-date/invalid version?
Thanks for all the help. I know Abel recommended Saxon. I need a processor that runs on Linux:


{hostname}125%> uname -a
Linux ######## 2.6.8-24.25-bigsmp #1 SMP Thu Aug 24 09:57:32 UTC 2006 i686 i686 i386 GNU/Linux


Sorry for being so dense on this. Thanks.
- Rob

On Feb 7, 2007, at 5:39 AM, Owen Rees wrote:

--On Tuesday, February 06, 2007 16:40:58 -0800 Rob Newman wrote:

You have got the point - your summary is correct.
Unfortunately that first sort (1) causes xsltproc to seg-fault again. I
will keep trying to figure it out.

This, which incorporates Abel's suggestions and a wrapper to handle the example input, works for me with xsltproc on Linux giving the result you are looking for with the larger example as input.


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform">


<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">

<dataloggerlist>
<xsl:apply-templates select="pfarr/pfarr/pfarr">
<xsl:sort select="pfstring[@name = 'dlt']" data- type="number" order="descending"/>
<xsl:sort select="@name"/>
</xsl:apply-templates>
</dataloggerlist>
</xsl:template>


   <xsl:template match="pfarr">
       <datalogger name="{@name}">
           <xsl:apply-templates select="pfstring"/>
       </datalogger>
   </xsl:template>

   <xsl:template match="pfstring">
       <param id="{@name}">
           <xsl:value-of select="."/>
       </param>
   </xsl:template>

</xsl:stylesheet>

Current Thread