Tempore 15:56:08, die 01/19/2005 AD, hinc in
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Ragulf Pickaxe
<jawxml(_at_)hotmail(_dot_)com>:
I have a hierarchic structure, that I would like to flatten.
I have tried looking for some examples, but I have not been able to
expand the examples I have found, so that they will work on my problem.
Hi,
The followng stylesheet will do the job when applied to the sample XML. It
most likely needs some modification to fit the real XML.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="mynode">
<xsl:apply-templates select="*[not(child::mynode)][position()=1 or
preceding-sibling::*[1]/child::mynode]" mode="encapsule"/>
<xsl:apply-templates select="../following::*[1]/mynode"/>
</xsl:template>
<xsl:template match="mynode/*" mode="encapsule">
<mynode>
<xsl:copy-of select="../@*"/>
<xsl:apply-templates select="." mode="list"/>
</mynode>
<xsl:apply-templates select="(following-sibling::*/mynode)[1]"/>
</xsl:template>
<xsl:template match="mynode/*" mode="list">
<xsl:copy-of select="."/>
<xsl:apply-templates select="following-sibling::*[1][not(child::mynode)]"
mode="list"/>
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
"Et ipsa scientia potestas est" - Francis Bacon , Meditationes sacrae
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--