Subject: How to test with XPath the existence of a certain branch of a <choice> statement?
From: "Ben Stover" <bxstover@xxxxxxxxxxx>
Date: Wed, 03 Feb 2010 20:50:56 +0100
|
For an XSLT script I need to check wether one certain branch of a <choice> statement is present.
The critical part of the XML statement look like as follows (<choice> and <sequence> are taken/inserted from the
underlying XSD schema file):
<parent>
<choice>
<sequence>
<aaa>...</aaa>
<bbb>...</bbb>
</sequence>
<sequence>
<aaa>...</aaa>
<ccc>...</ccc>
</sequence>
<sequence>
.....
</sequence>
</choice>
</parent>
As you can see a XML doc can contain one of the three sequence branches.
How do I check with XPath if the first branch is currently filled in an XML doc?
If I code e.g.
test=.../parent/aaa
then it is not clear if the first or second branch is present.
Can anyone give me a hint?
Thank you
Ben
|