This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: text() and not()


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]