xsl-list
[Top] [All Lists]

Re: [xsl] question on EXSLT data partitioning

2010-10-21 04:35:44
I had a good look at my xslt sheet and , i only use position in match key or 
with other context in use.
Sorry for that, my only excuse it's a very bad cold...

But could you test that, please ?

My xml example
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="D:\Mes 
documents\testxml\positioncle.xslt"?>
<a>
 <b>11</b>
 <b>12</b>
 <b>13</b>
 <b>14</b>
 <b>15</b>
 <b>16</b>
 <b>17</b>
 <b>18</b>
</a>


My XSLT example

<?xml version="1.0" encoding="UTF-8"?>
<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:key name="part" match="b[(position() - 1) mod 3!=0]" 
use="generate-id(../b[(position() - 1) mod 3=0  and 
((following-sibling::b)[position()&lt;3])[generate-id(.)=generate-id(current())]])"/>
 <xsl:template match="/">
  <r>
   <xsl:for-each select="*/b[(position() - 1) mod 3=0]">
    <c>
     <xsl:apply-templates select=".|key('part',generate-id(.))"/>
    </c>
   </xsl:for-each>
  </r>
 </xsl:template>
 <xsl:template match="b">
  <xsl:copy-of select="."/>
 </xsl:template>
</xsl:stylesheet>

I think it's too complicated and maybe it can be false but i'm curious to know 
what you think about idea 
----- Message d'origine ----- 
De : "Erwan AMOUREUX" 
<erwan(_dot_)amoureux(_at_)douane(_dot_)finances(_dot_)gouv(_dot_)fr>
À : <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Envoyé : jeudi 21 octobre 2010 09:36
Objet : Re: [xsl] question on EXSLT data partitioning


My mistake!
sorry
----- Message d'origine ----- 
De : "Michael Kay" <mike(_at_)saxonica(_dot_)com>
À : <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Envoyé : mercredi 20 octobre 2010 16:24
Objet : Re: [xsl] question on EXSLT data partitioning



For me it's logical
When you use global variable, current node is root, so with the key ,it's 
the same thing and position is calculated with the root as initial context


Whether it's logical or not, the specification is quite clear. In XSLT 1.0:

the expression specified in the use attribute of the xsl:key element is 
evaluated with x as the current node and with a node list containing 
just x as the current node list

So position() in the use expression returns 1.

Michael Kay
Saxonica

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--