I am trying to handle a xsd:choice in the B2B transformation engine.
(xsd examples here)
That is I have a
And I am only intrested in getting the "one" part
And I only want extract the "one" element not caring from which underlying type it comes from, i.e. I want to put the result into "one" below regardless if it comes from the thingyone, thingytwo or thingythree.
In XSLT terms I would like to do:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.differentthingies.com/20111119/thingy" xsi:schemaLocation="http://xmlns.differentthingies.com/20111119/thingy differentthinggies.xsd">
<differentthingies>
<thingythree>
<one>thisisthingythree1</one>
<three2>thisisthingythree2</three2>
<three3>thisisthingythree3</three3>
</thingythree>
</differentthingies>
</root>
Transformed by
<xsl:template match="/">
<xsl:variable name="var1_root" select="ns0:root"/>
<root xmlns="http://xmlns.differentthingies.com/20111119/anotherthingy">
<xsl:attribute name="xsi:schemaLocation" namespace="http://www.w3.org/2001/XMLSchema-instance">http://xmlns.differentthingies.com/20111119/anotherthingy thingy.xsd</xsl:attribute>
<thingyone>
<xsl:for-each select="$var1_root/ns0:differentthingies/ns0:thingyone/ns0:one">
<one>
<xsl:value-of select="string(.)"/>
</one>
</xsl:for-each>
<xsl:for-each select="$var1_root/ns0:differentthingies/ns0:thingythree/ns0:one">
<one>
<xsl:value-of select="string(.)"/>
</one>
</xsl:for-each>
<xsl:for-each select="$var1_root/ns0:differentthingies/ns0:thingytwo/ns0:one">
<one>
<xsl:value-of select="string(.)"/>
</one>
</xsl:for-each>
</thingyone>
</root>
</xsl:template>
Would become
<root xmlns="http://xmlns.differentthingies.com/20111119/anotherthingy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.differentthingies.com/20111119/anotherthingy thingy.xsd">
<thingyone>
<one>thisisthingythree1</one>
</thingyone>
</root>