Subject: Re: [xsl] How to test with XPath the existence of a certain branch of a <choice> statement? From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Wed, 03 Feb 2010 21:09:45 +0100 |
<xsl:template match="sequence"> ... </
<!-- catches all filled sequence nodes --> <xsl:template match="sequence[*]"> <xsl:text>found a filled sequence!</xsl:text> </
<!-- catches the rest, i.e., empty nodes (or nodes with only text) --> <xsl:template match="sequence"> <xsl:text>found an empty one!</xsl:text> </
<!-- contains at least an element --> <xsl:if test="sequence[*]">....</
<!-- contains element <aaaa> --> <xsl:if test="sequence[aaaa]">....</
<!-- contains any node, even a text node or comment node --> <xsl:if test="sequence[node()]">....</
<!-- any sequence --> <xsl:if test="sequence">....</
<!-- empty sequence element --> <xsl:if test="sequence[not(*)]">....</
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to test with XPath the ex, Ben Stover | Thread | [xsl] How to gracefully check if a , Calvados Boulard |
[xsl] How to test with XPath the ex, Ben Stover | Date | Re: [xsl] are all strings in a sequ, Justin Johansson |
Month |