This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: text() and not()
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 8 Jan 2002 11:54:29 -0000
- Subject: RE: [xsl] text() and not()
- Reply-to: xsl-list at lists dot mulberrytech dot com
> I have two points:
>
> 1. //*[not(name()='title')] matches all elements apart from
> the text in <title>
The text in <title> isn't an element, it is text.
To be pernickety, you should really write this as //*[not(self::title)] to
avoid namespace problems.
>
> //text()[not(name()='title')] matches all text, including that in
> <title>
>
> What xpath do I need to use to stop all text except that in <title>?
The name() of a text node is always "". You want
//text()[not(parent::title)]
or alternatively
//*[not(self::title)]/text()
>
> 2. If I use the default template to output the contents of
> <title>, how do
> I obtain the same sort of result as:
>
> <xsl:template match="para0/title">
> <p class="title"><xsl:value-of select="."/></p>
> </xsl:template>
>
I don't understand. If you use the default (Built-in) template rule to
output <title> elements, it will just output the textual content of the
<title> element. If you want to wrap it in a <p> element, you must use a
template rule like the one you've shown us, you can't use the built-in
template rule.
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list