xsl-list
[Top] [All Lists]

[xsl] Re: building a hierarchical classification out of flat and redundant data

2006-07-26 05:26:58
Albert Juhé wrote:
Hi,

I have been trying the code, and the output it's not that I expect
because the tag subunit is identet inside another subunit like this

</sub-sub-subunit>
</sub-subunit>
</sub-subunit>
</sub-subunit>
</sub-subunit>
</sub-subunit>
</sub-subunit>


And there are duplicated nodes

The duplicated nodes could be explained if there are indeed
sub-sub-subunit's that are not preceeded by a matching sub-subunit,

I wrote templates that could point to this case, by showing the
preceeding subunit's:

<xsl:template match="/modul">
        <xsl:apply-templates/>
</xsl:template>

<xsl:template match="unit">
        <xsl:apply-templates select="subunit"/>
</xsl:template>

<xsl:template match="subunit">
        <xsl:apply-templates select="following-sibling::node()[1]" 
mode="check"/>
</xsl:template>

<xsl:template match="node()" mode="check">
        <xsl:apply-templates select="following-sibling::node()[1]" 
mode="check"/>
</xsl:template>

<xsl:template match="sub-sub-subunit" mode="check">
        <xsl:text>&#10;inproper nesting starting with node &#10;</xsl:text>
        <xsl:copy-of select="preceding-sibling::subunit[1]"/>
        <xsl:copy-of select="current()"/>
</xsl:template>

<xsl:template match="sub-subunit" mode="check"/>


--~------------------------------------------------------------------
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>
--~--