DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20531>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20531

Variables not supported in <sort>





------- Additional Comments From [EMAIL PROTECTED]  2003-06-06 12:44 -------
Hmm... It seems that you are right. I had been fooled by the fact that THIS 
version (where I've declared the variable immediately before the <sort> but 
didn't USE it in the sort):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template match="/">
    <TopNode>
      <xsl:for-each select=".">
        <xsl:variable name="foo" select="'bar'"/>
        <xsl:sort select="'abc'"/>
        <InnerNode/>
      </xsl:for-each>
    </TopNode>
  </xsl:template>
</xsl:stylesheet>

DID work, (and technically shouldn't have). So I guess this is not a valid bug.

Unfortunately, it doesn't solve my problem, which now turns out to be a flaw in 
the design of XSLT, not in the apache implementation. I have a document 
structured like this:

<Top>
  <SortCriteria>
    <Criterion order="2">abc</Criterion>
    <Criterion order="1">def</Criterion>
    <Criterion order="3">ghi</Criterion>
  </SortCriteria>
  <Data>
    <Datum otherInfo="ipso">abc</Datum>
    <Datum otherInfo="post">def</Datum>
    <Datum otherInfo="facto">ghi</Datum>
  </Data>
</Top>

What I want is to do a <for-each> in which I loop through the <Datum> elements, 
sorted according to the order attribute in the corresponding <Criterion> 
element. Something like this would do it:

   ...
     <xsl:for-each select="/Top/Data/Datum">
       <xsl:variable name="datum-value" select="string(.)"/>
       <xsl:sort select="/Top/Criteria/Criterion[.=$datum-value]/@order"/>
       Template Here <xsl:value-of select="@otherInfo"/>
     </xsl:for-each>
   ...

but unfortunately, it's not legal. Sorry for the erronious bug report. I'll 
seek another solution -- looks like XSLT isn't up to this task.

-- Michael Chermside

Reply via email to