Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 9/5/2008 2:01:00 PM

Arndt Jonasson wrote:
> 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.

Even in the XSLT 2.0 data model the txt element has a child node, it is 
a text child node. So your description of saying does not have "children 
in the schema" is not very precise. Are you looking for elements which 
have a simple type in the meaning of the W3C schema language, meaning 
they have no child _elements_ and no attributes? I am not sure whether 
schema aware XSLT 2.0 allows you do detect elements which have a simple 
type respectively do distinguish in your stylesheet between elements 
having a simple type and those having a complex type. As far as I know 
all you can do is match an element based on its type and validate input 
or output elements based on a schema.

You might want to ask on the XSL mailing list 
http://www.mulberrytech.com/xsl/xsl-list/, spec writers and implementors 
like Michael Kay are regulars there so you should get a more qualified 
answer there than here.



-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent