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

Distinguish between empty string and no children, in

Subject: Distinguish between empty string and no children, in XPath 2?
From: Arndt Jonasson <arndt@xxxxxxxxxx>
Date: Fri, 5 Sep 2008 14:33:02 +0200
 Distinguish between empty string and no children
Hello,

I hope this is the right forum for this question. I asked it first
in the new group comp.text.xml, but was directed here. It has nothing
directly to do with XSLT, only with XPath.


Let's say we have a schema (maybe expressed in XML Schema, but not
necessarily so), that allows this instance document:

<top>
  <txt>This is text</txt>
  <books>
    <book>Tarzan</book>
    <book>Harry Potter</book>
  </books>
</top>

The text /top/txt may be empty, and the element /top/books may have no
children, so this instance document is also allowed:

<top>
  <txt/>
  <books/>
</top>

I now want to write an XPath expression that selects all nodes that do
not have child elements in the schema. It would always select /top/txt
and it would never select /top/books, even in the second example
above.

With XPath 1.0, this is not possible, since schema information is not
used there. But can it be done in XPath 2.0? I find the standard
document a bit forbidding, although I'm fairly well acquainted with
the 1.0 document.

We would like to add such capability to the XPath 1.0 implementation
in our application (which does have access to the schema), and if
XPath 2.0 offers a way to express it, it seems best not to reinvent
anything, hence this question.

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.