XSL Transformation
-
How to transform this using XSL ? <TAGNAMES> <TAGNAME a="1" b="2"> <TAGNAME a="1" b="3"> . . <TAGNAME a="2" b="4"> <TAGNAME a="2" b="5"> . . <TAGNAMES> to the form <P> <X x="1"> <Y="2"> <Y="3"> . . </X> <X x="2"> <Y="4"> <Y="5"> . . </X> </P> Thank you! :)
-
How to transform this using XSL ? <TAGNAMES> <TAGNAME a="1" b="2"> <TAGNAME a="1" b="3"> . . <TAGNAME a="2" b="4"> <TAGNAME a="2" b="5"> . . <TAGNAMES> to the form <P> <X x="1"> <Y="2"> <Y="3"> . . </X> <X x="2"> <Y="4"> <Y="5"> . . </X> </P> Thank you! :)
Actually this isn't valid XML. No closing of the TAGNAME tags. I'm affraid what you are trying to do may not be possible in a general case :(( . If the A values are from a known set you can probably do it, by doing an xsl:if and a xsl:foreach for each possible value
<xls:if select="TAGNAME[@x='1']"> <xsl:foreach select="TAGNAME[@1='1']"> ...
The absence of genuinely variable variables in XSL otherwise rather screws you up. -
How to transform this using XSL ? <TAGNAMES> <TAGNAME a="1" b="2"> <TAGNAME a="1" b="3"> . . <TAGNAME a="2" b="4"> <TAGNAME a="2" b="5"> . . <TAGNAMES> to the form <P> <X x="1"> <Y="2"> <Y="3"> . . </X> <X x="2"> <Y="4"> <Y="5"> . . </X> </P> Thank you! :)
jenitennison.com is very helpful. It shows how to group XML elements based on keys.