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

Subject: [xsl] Are nested brackets legal? Is this the same as positional grouping?
From: Abel Online <abel.online@xxxxxxxxx>
Date: Wed, 16 Aug 2006 20:25:38 +0200
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][@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>

Abel Braaksma

Current Thread