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

Re: How to find the parent.

Subject: Re: How to find the parent.
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 4 May 2001 16:34:30 +0100
find a parent
Hi Pedro,

> I would like to know if it is possible, once you have find a target
> element (whatever kind of element is), to find out which is its
> father.

I always thought of elements as mothers ;)

> A typical example would be looking for a substring and once find it
> getting to know inside which element is included (paragraph, title,
> ...). In fact, as the first query could produce a text-node result
> set, but the actual question would be finding the result set of the
> fathers.
>
> Example:
>
> query = in which elements the string " Shakespeare" is included.

You'd probably be best off getting this by matching all those text
nodes that include the string ' Shakespeare', and then getting their
parent element.  You can get the parent with the XPath:

  ..

And then get its name with the name() function:

<xsl:variable name="query" select="' Shakespeare'" />

<xsl:template match="text()">
   <xsl:if test="contains(., $query)">
      <xsl:text>Query string contained in:</xsl:text>
      <xsl:value-of select="name(..)" />
   </xsl:if>
</xsl:template>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.