Re: [xsl] xsltproc complains about xsl:sort

Subject: Re: [xsl] xsltproc complains about xsl:sort
From: Ed_Owen@xxxxxxxxxxxxxxxxxxxx
Date: Tue, 3 Aug 2004 14:07:49 -0700
M. David,

Thanks for the explanations and suggestions. I've unraveled what was going
on:

(1) The xsltproc error messages were happening because xsltproc was taking
this line of the XSLT (note newlines and tabs):

      <xsl:for-each test="footest">
            <xsl:sort select="foo"/>

And seeing:

<xsl:for-each test="footext">[CR/LF][TAB]<xsl:sort select="foo"/>

The [CR/LF][TAB] is seen as a text node, and so therefore the <xsl:sort>
element is not the first child element of the <xsl:for-each>, and so
xsltproc complains.

This strikes me as a bit odd, because the root element is <xsl:stylesheet
... xmlspace="default">, so I'm not sure why it's trying to preserve the
whitespace (I thought "default" did NOT preserve whitespace). But that's
definitely what it is trying to do based on the -v log I recorded from
xsltproc.

Removing the [CR/LF][TAB] and putting the <xsl:sort> on the same line as
the <for-each> solved the problem.

(2) The duplications I was seeing were due to some newbie select="" syntax
I was using.

I had:

      select="/element1[predicate]/childelement1/childelement2[predicate]"

when I should have been using:

      select="/element1[predicate and
childelement1/childelement2[predicate]]"

My syntax was producing too many/duplicate matches for element1's.

thanks
Ed

Current Thread