|
Subject: Re: [xsl] ancestor/subsequent descendant test From: Michael Ludwig <mlu@xxxxxxxxxxxxx> Date: Fri, 27 Mar 2009 17:29:52 +0100 |
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')]) ]
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.
<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][@sig='Y']">
<xsl:attribute name="INSIGNIFICANT">Y</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] ancestor/subsequent desce, G. Ken Holman | Thread | [xsl] xhtml2cals table stylesheet, Roman Huditsch |
| Re: [xsl] ancestor/subsequent desce, G. Ken Holman | Date | [xsl] xhtml2cals table stylesheet, Roman Huditsch |
| Month |