[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Top N Most Common Mistakes

Michael Kay mike at saxonica.com
Sun Aug 5 20:23:08 PDT 2007


  Top N Most Common Mistakes
> 3) Use of ".../text()" when the user really means 
> ".../data()" or ".../string()" (or should rely on implicit 
> atomization). The trouble is that the answer (after implicit 
> atomization and casting) is often the same, but the meaning 
> is entirely different. This can cause schema-less XML 
> databases like Berkeley DB XML to be unable to use it's 
> indexes in these cases.

Using a schema doesn't actually help, because

a/text() = 'fred'

will match the element

<a>fred<!--that was the short name-->erica</a>

and the schema tells you nothing about comments.

Saxon-SA's on-demand indexing handles this, because it's based on the
predicates actually used in the query: if the query is foo[a/text()='fred']
then the index will be on a/text(), so the indexed values will be "fred" and
"erica". But if there's a persistent index then of course it's likely to be
on the string value or the typed value of the element, which certainly
doesn't help this query.

Unfortunately the /text() usage appeared in very early versions of the
XQuery use cases, and it has been perpetrated in tutorials, textbooks,
academic papers, and benchmarks ever since. It's very rarely seen in XSLT
code, even among beginners, which shows how influential a few published
examples can be.

Michael Kay
http://www.saxonica.com/




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-2007 All Rights Reserved.