[XSL-LIST Mailing List Archive Home]
[Reply To This Message]
Re: How to copy only the really existing <choice> bra
Subject: Re: How to copy only the really existing <choice> branch/element? "value-of-if-exist"|
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 07 Oct 2009 14:18:51 +0200
Ben Stover wrote:
Assume I have a XML source based on the following (simplified) XSD schema:
<xsd:element name="top" type="mytype"/>
<xsd:element name="aaa" type=".....">
<xsd:element name="bbb" type=".....">
<xsd:element name="ccc" type=".....">
That mean either element aaa or element bbb or element ccc is filled/exists.
Now I want to copy only this sub-element to a target which currently exists.
If I simply write:
then ALL three elements were copied. The 2 branches which do not exist were created
as empty elements so that the target XML doc looks like e.g.
which is an invalid XML because of its XSD schema file definition.
xsl:value-of never creates an elements at all thus I don't see how
<xsl:value-of select="ccc"/> would create any element at all in the output.
So somehow I am not sure which problem you face, if there is e.g. no
'ccc' element in the input then neither
will output any element.
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format