[Home] [By Thread] [By Date] [Recent Entries]
Hi Rick,
As I said, I would use sibling recursion. Start at the first Category element and walk the following-sibling axis, like this <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output indent="yes" /> <xsl:template match="Cases/Cases">
<Cases>
<xsl:apply-templates select="Category[1]" />
</Cases>
</xsl:template><xsl:template match="Category"> <Case> <xsl:copy-of select="." /> <xsl:apply-templates select="following-sibling::*[1][not(self::Category)]" mode="in-case-siblings"/> </Case> <xsl:apply-templates select="following-sibling::Category[1]"/> </xsl:template> <xsl:template match="*" mode="in-case-siblings"> <xsl:copy-of select="." /> <xsl:apply-templates select="following-sibling::*[1][not(self::Category)]" mode="in-case-siblings"/> </xsl:template> <xsl:template match="Category" mode="in-case-siblings"/> </xsl:stylesheet> Cheers Geert At 02:57 17/03/2013, you wrote: I am trying to add hierarchy to a flat structure and have it basically working. But I am wondering if there is a way to generalize the children that I am adding. Hopefully an example will help illustrate what I am doing.
|

Cart



