xsl-list
[Top] [All Lists]

Re: check for ancestors attribute

2005-02-08 04:19:28

How do I need to extend this template to match not only <foo
name="bar"> but further restrict my template to those <foo>s that have
an ancestor with attribute type="general". 

<xsl:template match="foo[(_at_)name='bar']">

the direct translation of what you wrote would be

<xsl:template match="foo[(_at_)name='bar'][ancestor::*[(_at_)type='general']]">

although I'd probably write that as


<xsl:template match="*[(_at_)type='general']//foo[(_at_)name='bar']">


It seem to be not OK to write:

<xsl:template match="foo[(_at_)name='bar' and ancestor::@type='general']">

@ is attribute:: and you can't use two axese in one step, that should
have been


<xsl:template match="foo[(_at_)name='bar' and ancestor::*/@type='general']">

which is equivalent to the first form above.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>