Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Distinguish between empty string and no children, in XPath 2?

Reply
Thread Tools

Distinguish between empty string and no children, in XPath 2?

 
 
Arndt Jonasson
Guest
Posts: n/a
 
      09-05-2008

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 children 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
It seems that XPath does not distinguish between an inexistent pathand a null string? Ramon F Herrera XML 13 06-28-2012 01:14 PM
Distinguish between empty string and no children, in XPath 2? Arndt Jonasson XML 6 09-07-2008 04:48 AM
behavior varied between empty string '' and empty list [] Tzury Bar Yochay Python 1 03-24-2008 06:56 PM
distinguish between char* and char[x] mosfet C++ 6 11-27-2003 01:28 AM
How to distinguish between Olympus refurbished and new? Jerry Nash Digital Photography 4 11-19-2003 05:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57