RE: [xsl] strange issue with execution order of range expression (for $x in 1 to $y) [SOLVED]

Subject: RE: [xsl] strange issue with execution order of range expression (for $x in 1 to $y) [SOLVED]
From: "Robby Pelssers" <robby.pelssers@xxxxxxxxx>
Date: Thu, 17 Dec 2009 14:28:18 +0100
Ok... my mistake.

I do some sorting later on in the pipeline which sorts the rows based on it's

Sorry about this.

-----Original Message-----
From: Robby Pelssers [mailto:robby.pelssers@xxxxxxxxx]
Sent: Thursday, December 17, 2009 2:18 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] strange issue with execution order of range expression (for
$x in 1 to $y)

Hi Andrew,

I'm using Saxon8.7 for my projects.  It's also the default version of Saxon
used with Apache Cocoon2.2 and I've been using it for the last 2 years.

I wrote a little simplified version

<xsl:copy-of select="for $i in (1 to $rowSize) return nxp:getRow($i)"/>

  <xsl:function name="nxp:getRow">
    <xsl:param name="rowIndex"/>
    <row rowIndex="{$rowIndex}"/>

Which produces  correctly
   <row rowIndex="1"/>
   <row rowIndex="2"/>
   <row rowIndex="3"/>
   <row rowIndex="4"/>
   <row rowIndex="5"/>

The only difference I see is that I pass on multiple function arguments AND I
reference globally declared variables in this function (closure).  Could the
last be messing up execution order somehow?

I'm willing to create a similar simplified setup and try if I can reproduce a
similar issue.

Robby Pelssers

-----Original Message-----
From: Andrew Welch [mailto:andrew.j.welch@xxxxxxxxx]
Sent: Thursday, December 17, 2009 2:03 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] strange issue with execution order of range expression (for
$x in 1 to $y)

removing all of the irrelevant code, that simplifies down to:

<xsl:function name="nxp:getPinningTableRow">
  <xsl:param name="rowIndex"/>
  <row rowIndex="{$rowIndex}"/>

<xsl:template match="/">
    <xsl:copy-of select="for $i in (1 to 5) return

which outputs:

   <row rowIndex="1"/>
   <row rowIndex="2"/>
   <row rowIndex="3"/>
   <row rowIndex="4"/>
   <row rowIndex="5"/>

using Saxon

If you get something different with the above, post back with your set up.


2009/12/17 Robby Pelssers <robby.pelssers@xxxxxxxxx>:
> Hi all,
> I have following template which calls a custom function I wrote for a
certain range:
>   <!--
>    | This template handles the Topic 'Pinning information'  (->
CharacteristicSet 'Pinning information')
>    | Note: We need to take the simplified outline graphic from the package
instead of the product
>    -->
>   <xsl:template match="Topic[@id='pinning_information']" mode="topic">
>     <xsl:variable name="pinChar"
m) and Parameter/@DETIdentifier='PAE050']"/>
>     <xsl:variable name="symbolChar"
m) and Parameter/@DETIdentifier='PAE051']"/>
>     <xsl:variable name="descriptionChar"
m) and Parameter/@DETIdentifier='PAE061']"/>
>     <xsl:variable name="simplifiedOutline_FigureCode"
and Parameter/@DETIdentifier='PAF008']/Values/Value"/>
>     <xsl:variable name="graphicSymbol_FigureCode"
m) and Parameter/@DETIdentifier='PAF002']/Values/Value"/>
>     <!-- we can count the rowSize based on pin, symbol or description rows,
here we count the number of pin rows-->
>     <xsl:variable name="rowSize" select="count($pinChar/Values/Value)"/>
>     <p-topic id="{@id}">
>       <title><xsl:value-of select="@title"/></title>
>       <xsl:call-template name="prolog"/>
>       <body>
>         <table tabletype="nonQuantitative">
>           <title><xsl:value-of select="if (@tabletitle) then @tabletitle
else @title"/></title>
>           <tgroup cols="5">
>             <colspec colnum="1" colname="col1" colwidth="*"/>
>             <colspec colnum="2" colname="col2" colwidth="*"/>
>             <colspec colnum="3" colname="col3" colwidth="*"/>
>             <colspec colnum="4" colname="col4" colwidth="*"/>
>             <colspec colnum="5" colname="col5" colwidth="*"/>
>             <thead>
>               <row>
>                 <entry colname="col1">
>                   <p>Pin</p>
>                 </entry>
>                 <entry colname="col2">
>                   <p>Symbol</p>
>                 </entry>
>                 <entry colname="col3">
>                   <p>Description</p>
>                 </entry>
>                 <entry colname="col4">
>                   <p>Simplified outline</p>
>                 </entry>
>                 <entry colname="col5">
>                   <p>Graphic symbol</p>
>                 </entry>
>               </row>
>             </thead>
>             <tbody>
>               <xsl:copy-of select="for $i in (1 to $rowSize) return
(nxp:getPinningTableRow($rowSize, $i, $pinChar, $symbolChar, $descriptionChar,
$simplifiedOutline_FigureCode, $graphicSymbol_FigureCode))"
>             </tbody>
>           </tgroup>
>         </table>
>       </body>
>     </p-topic>
>   </xsl:template>
>   <xsl:function name="nxp:getPinningTableRow">
>     <xsl:param name="rowSize"/>
>     <xsl:param name="rowIndex"/>
>     <xsl:param name="pinChar"/>
>     <xsl:param name="symbolChar"/>
>     <xsl:param name="descriptionChar"/>
>     <xsl:param name="simplifiedOutline_FigureCode"/>
>     <xsl:param name="graphicSymbol_FigureCode"/>
>     <row rowIndex="{$rowIndex}"/>
>   </xsl:function>
> The weird thing is that the generated <tbody> looks like
> <tbody>
>   <row rowIndex="5"/>
>   <row rowIndex="1"/>
>   <row rowIndex="2"/>
>   <row rowIndex="3"/>
>   <row rowIndex="4"/>
> </tbody>
> Is a range not supposed to be executed in order 1 -> 2 -> 3-> 4-> 5 ??  Or
what could potentially mess-up the execution order of calling this function?
> Robby Pelssers

Andrew Welch

Current Thread