Quote:
Originally Posted by Martin Honnen
Here is an XSLT 2.0 stylesheet assuming you have those 'para' elements wrapped in a 'root' element:
Code:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xsd">
<xsl:output indent="yes"/>
<xsl:template match="root">
<xsl:copy>
<xsl:for-each-group select="para" group-by="tag/@name">
<mainlist name="{current-grouping-key()}">
<xsl:for-each select="current-group()/paraline/string">
<list><text><xsl:value-of select="."/></text></list>
</xsl:for-each>
</mainlist>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
|
Thank you very much for the quick reply.
The group-by does not solve my problem. The problem comes when the para no tags element. The out put should be simple Paraline/String text should be in <text> tags only like
Code:
<para>
<tag name="bullet"/>
<paraline>
<string>One</string>
</paraline>
</para>
<para>
<tag name="bullet"/>
<paraline>
<string>Two</string>
</paraline>
</para>
<para>
<paraline>
<string>THANK YOU</string>
</paraline>
</para>
<para>
<tag name="Number"/>
<paraline>
<string>11111</string>
</paraline>
</para>
<para>
<tag name="Number"/>
<paraline>
<string>22222</string>
</paraline>
</para>
output should be
Code:
<mainlist name="bullet">
<list>
<text>One</text>
</list>
<list>
<text>Two</text>
</list>
</mainlist>
<text>THANK YOU</text>
<mainlist name="Number">
<list>
<text>11111</text>
</list>
<list>
<text>22222</text>
</list>
</mainlist>