[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: ancestor/subsequent descendant test

Subject: Re: ancestor/subsequent descendant test
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Fri, 27 Mar 2009 17:29:52 +0100
Re:  ancestor/subsequent descendant test
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][@sig='Y']">
        <xsl:attribute name="INSIGNIFICANT">Y</xsl:attribute>
      </xsl:if>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.