I'm currently trying to convert a section of a very messy xml to something more readable, but when my code isn't producing what I want.
Could I get some feedback on what's wrong with my code, and how I can fix it?
Example input:
<root>
<body>
<para>
<heading> name </heading>
</para>
<para> This is the name </para>
<para>
<heading> Usage </heading>
</para>
<para> This is the usage </para>
</body>
<root>
The output I'd like to see is:
<root>
<conbody>
<section>
<title> Name </title>
<p> This is the name </p>
</section>
<section>
<title> Usage </title>
<p> This is the usage </p>
<conbody>
<root>
My code currently looks like this:
<xsl:template match="body">
<conbody>
<xsl:for-each-group select="para" group-starting-with="para[heading]">
<section>
<title>
<xsl:apply-templates select="element()"/>
</title>
<p>
<xsl:apply-templates select="*"/>
</p>
</section>
</xsl:for-each-group>
</conbody>
</xsl:template>
The content is not being copied correctly, and I'm not sure why?
current-group()[1]
in the firstxsl:apply-templates
andcurrent-group()[not(position()=1)]
in the secondxsl:apply-templates
. – Daniel Haleypara
in/out oftitle
. The grouping looks right; unless I'm missing something? – Daniel Haley