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

Re: How to test if a node is a descendant of a specifi

Subject: Re: How to test if a node is a descendant of a specific ancestor
From: Ronald <ronald@xxxxxxxxxxx>
Date: Thu, 26 Apr 2001 14:59:03 +0100
xsl if descendant
It seems to me some reading on xsl and xpath would do much for you.

If you haven't got the time to do so, here's the code :-)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          version="1.0">

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

<xsl:template match="//string">
  <xsl:if test="ancestor::head-row">
      <p class="head-row">some content1</p>
  </xsl:if>

  <xsl:if test="ancestor::body-row">
      <p class="body-row">some content2</p>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>


Ronald


At 02:47 PM 4/26/01 +0200, you wrote:
Hello!

I have an xml file that looks like the following:

<layout>
    <head-row>
        <data>
            <string>
            </string>
        </data>
    </head-row>

    <body-row>
        <data>
            <string>
            </string>
        </data>
    </body-row>
</layout>

Then I have a template rule in an XSL file that looks like the following:

<xsl:template match="//string">
.......Pseudo code:
<test if the current context node is a descendant of head-row>
    <p class="head-row">some content</p>
</test>

<test if the current context node is a descendant of body-row>
    <p class="body-row">some content</p>
</test>
...........


How can I test this?



Sebastian Schirmer


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


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-2013 All Rights Reserved.