xsl-list
[Top] [All Lists]

[xsl] Are nested brackets legal? Is this the same as positional grouping?

2006-08-16 11:25:51
Hi List,

Not sure if I state this correctly, but here's what I am trying to achieve: Select all "row" nodes where the second cell contains "selected-id = $table-id". What I have is the following:

<xsl:apply-templates select="twz:rows/twz:row[twz:cell/@selected-id = $car-id]" />

But that is clearly not working when the fourth cell with 'selected-id' is having a value equal to $car-id (see XML snippet below: more cells may have a "selected-id", only the second cell is important here)

Now for something that surprised me. The following appeared to be working in TransformIIX (Gecko, client-side XSLT 1.0). Not sure it works with other xslt/xpath processors though. But I must say, it is mighty handy.

<xsl:apply-templates select="twz:rows/twz:row[twz:cell[2]/@selected-id = $car-id]" />

From what I found on the web and on this list, it appears that subsequent bracketing (//node[cell][2][item][3]) is allowed, but nested bracketing not. Can someone shine some light on this? It works for me, but it gives me a bit of a strange feeling ;-) . Some people had some posts recently on positional grouping. I had some trouble understanding what was going on, but isn't this basically the same?

The following is a legal variant, but does not actually do what I want:

<xsl:apply-templates select="twz:row[twz:cell][2][(_at_)selected-id = $table-id]" />


*** SAMPLE XML ****
<data>
  <rows>
     <row id="1">
        <cell>Filename 3</cell>
        <cell selected-id="1">Car A</cell>
        <cell>exported_filename.xml</cell>
        <cell selected-id="3">Company 1</cell>
     </row>
     <row id="2">
        <cell>Filename 1</cell>
        <cell selected-id="1">Car A</cell>
        <cell>xyz.xml</cell>
        <cell selected-id="3">Company 1</cell>
     </row>
     <row id="3">
        <cell>Filename 1</cell>
        <cell selected-id="2">Car OTHER</cell>
        <cell>other.xml</cell>
        <cell selected-id="2">Other company</cell>
     </row>
  </rows>
</data>

Cheers,
Abel Braaksma
http://www.nuntia.nl



--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>