XSLT transform question

Associate
Joined
6 Jun 2004
Posts
2,389
Location
London
More of an XPATH question actually:

When I'm applying XSLT templates to particular nodes, is there anyway I can select an element based on the existance of a child element?

For example:

Code:
<root>
  <elem>
  </elem>
  <elem>
    <child/>
  </elem>
  <elem>
  </elem>
</root>
I want to pick the middle <elem> element. If there was two <elem> elements with <child/> present, you can pick one at random (I assume first or last would be easiest).

I don't want to use select="root/elem[last()]" since that would pick the last one. Obviously I can't use "root/elem[0]" either.

Is there anyway I can do this?
 
Back
Top Bottom