[Home] [By Thread] [By Date] [Recent Entries]
nick public nickpubl@xxxxxxxxx wrote:
I need to convert a flat structure like this Can't you use XSLT 2.0 with <xsl:template match="root">
<xsl:copy>
<xsl:for-each-group select="*" group-starting-with="H">
<xsl:copy>
<xsl:apply-templates select="node(), current-group() except ."/>? That way it is easy to process your input. With XSLT 1.0 you might want to define a key <xsl:key name="group" match="I" use="generate-id(preceding-sibling::H[1])"/> and then you can use <xsl:template match="root">
<xsl:copy>
<xsl:apply-templates select="H"/>
</xsl:copy>
</xsl:template><xsl:template match="H">
<xsl:copy>
<xsl:apply-templates select="node() | key('group', generate-id())"/>
</xsl:copy>
</xsl:template>Both approaches need the identity transformation template to copy the remaining nodes like the I elements.
|

Cart



