|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xml to xml mapping - how to combine two groups
<x>
<LIST_GROUP_A>
<GROUP_A>
<COLOR>red</COLOR>
</GROUP_A>
</LIST_GROUP_A>
<LIST_GROUP_B>
<GROUP_B>
<SHAPE>round</SHAPE>
</GROUP_B>
<GROUP_B>
<SHAPE>square</SHAPE>
</GROUP_B>
</LIST_GROUP_B>
</x>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="x">
<LIST_COMBINED>
<xsl:variable name="a" select="LIST_GROUP_A/*"/>
<xsl:variable name="b" select="LIST_GROUP_B/*"/>
<xsl:for-each select="$a|$b[position()>count($a)]">
<xsl:variable name="p" select="position()"/>
<COMBINED>
<xsl:copy-of select="$a[$p]/*|$b[$p]/*"/>
</COMBINED>
</xsl:for-each>
</LIST_COMBINED>
</xsl:template>
</xsl:stylesheet>
$ saxon map.xml map.xsl
<?xml version="1.0" encoding="utf-8"?>
<LIST_COMBINED>
<COMBINED>
<COLOR>red</COLOR>
<SHAPE>round</SHAPE>
</COMBINED>
<COMBINED>
<SHAPE>square</SHAPE>
</COMBINED>
</LIST_COMBINED>
|
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
|






