Trevor Nicholls schrieb:
My input documents are allowed to contain nested sections. An optional
attribute marks out certain sections as significant. I want to detect
a situation in which a section which contains a descendant significant
section does not contain a subsequent INsignificant section (other
than descendants of any significant sections).
section//section[ @sig='Y' ]
[ not(following-sibling::section[1][not(@sig='Y')]) ]
Could this be it?
The section .D. is OK because it is within a "significant section",
but if the section it is wrapped in did not have the significant
attribute set then I want to report it, because it is INsignificant
and a descendant of a section which contains a prior significant
section.
Maybe the following does what you want, but I'm not sure.
Michael Ludwig
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="section[ not(@sig='Y') ]">
<xsl:copy>
<xsl:if test="
ancestor::section[1][not(@sig='Y')]
/
preceding-sibling::section[1][(_at_)sig='Y']">
<xsl:attribute name="INSIGNIFICANT">Y</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--~------------------------------------------------------------------
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>
--~--