[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to find the 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|