Angus McIntyre
Usenet Archive
- Joined
- May 15, 2001
- Messages
- 12
- Reaction score
- 0
Can this be done with XPath?
I have input XML that is basically of the form:
<list>
<item att="a">s1</item>
<item att="a">s2</item>
<item att="b">s3</item>
<item att="c">s4</item>
<item att="c">s5</item>
</list>
I need to produce output of the form:
1. s1, s2
2. s3
3. s4, s5
Another way of looking at this is to say that I need to know the position of a given '<item>' node in the list of item nodes whose attribute 'att' is not the same as that of the preceding node.
(It's a little more complex because I actually need to test two attributes for non-equality with the attributes of the preceding sibling, but that's OK).
Is there a way to either (a) get a count of preceding siblings of the current context node that pass a given test (the test depending on relative properties of the siblings), or (b) to get the position of the current context node in a list of nodes which is _not_ the same as the current context nodelist.
Advice, even of the form "No, it's not possible, give up", would be very welcome.
Thanks
Angus
I have input XML that is basically of the form:
<list>
<item att="a">s1</item>
<item att="a">s2</item>
<item att="b">s3</item>
<item att="c">s4</item>
<item att="c">s5</item>
</list>
I need to produce output of the form:
1. s1, s2
2. s3
3. s4, s5
Another way of looking at this is to say that I need to know the position of a given '<item>' node in the list of item nodes whose attribute 'att' is not the same as that of the preceding node.
(It's a little more complex because I actually need to test two attributes for non-equality with the attributes of the preceding sibling, but that's OK).
Is there a way to either (a) get a count of preceding siblings of the current context node that pass a given test (the test depending on relative properties of the siblings), or (b) to get the position of the current context node in a list of nodes which is _not_ the same as the current context nodelist.
Advice, even of the form "No, it's not possible, give up", would be very welcome.
Thanks
Angus