xsl-list
[Top] [All Lists]

RE: Getting the data type of an element

2004-01-13 10:17:39

How can a sequence of anything be an instance of xs:boolean Mike?

In the XPath data model true() is both a boolean and a sequence
containing a single boolean. There is no distinction between an item and
a sequence of length one containing that item.

This reflects the way list-valued attributes work in XML Schema (and in
DTDs): you wouldn't expect the attribute value "red" to behave
differently when you change the type from NMTOKEN to NMTOKENS. 


<xsl:if test=". instance of xs:boolean">

I'd interpret that as 'the context node value is a boolean'. 
What's the difference between . and data(.) please?

data(.) forces atomization (i.e. extracting the value of a node). If X
is an element then it cannot be a boolean, but its content can be a
boolean. Many operators such as "+" and "=" force atomization of their
operands, but some, like count() and "instance of", do not. For example
with an NMTOKENS attribute a="red green blue", count(@a) is 1 but
count(data(@a)) is 3.

Are  you are assuming the context is a sequence of one item?
 
There is a thing called the "context item" which is either a single item
(=a sequence of one item) or is undefined (loosely, null).

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>