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

Re: why not match text()? (fork from "Novice Question

Subject: Re: why not match text()? (fork from "Novice Question - matching entire text children")
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 21 Dec 2010 10:33:32 +0000
Re:  why not match text()? (fork from "Novice Question
This might be a common problem from people coming from XQuery... in
XSLT we get the string value of the element or attribute, in XQuery
you get the deep-copy, so there is the habit of specifying string()
everywhere (or text() in the past)
Yes. In XSLT it's natural to do

<book><xsl:value-of select="title"/></book>

In XQuery it's best to do

<book>{string(title)}</book>

but many examples and tutorials encourage

<book>{title/text()}</book>

which works fine until someone has a title that reads:

<title>On the freezing point of H<sub>2</sub>O</title>

As to using template rules that match text nodes, I think the discussion we've been having shows that it's legitimate if you have mixed content and need to something with the content of the text other than copying it or discarding it; but you do need to be aware that the text can be split up into multiple text nodes by comments or other markup.

Michael Kay
Saxonica

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.