RE: Typed value trees & [Bug 1824: Functions return xs:NCName, but xs:NCName is not support in XSLT 2.0 Basic]

> Like a clever rabbit...

It's known within the working group as the "white horse". We spent a long
time grappling with the general problem of consistency between run-time
types and compile-time types.

> The 
> controversial 
> part according to me is that the resulting value isn't what 
> the spec claim it 
> to be(the result value isn't of type xs:NCName, but xs:string).

It might be an xs:NCName, but there is no way of telling. In the same way as
a Java method declared to return a List can actually return a
MySpecialDoubleLinkedList, you really don't care that the function returned
a value of a type you don't know about, so long as it conforms to a type you
do know about. 

> Therefore, it have 
> that as assumption: the user cannot determine whether the 
> resulting value is 
> an instance of xs:NCName, the type it claims to be.

Quite.
> 
> Can that assumption be broken elsewhere?

If so, then a lot of things are broken. (Actually, in the Java analogy, you
can find out that the returned value is a MySpecialDoubleLinkedList, and you
can get a lot of information from the metadata for this class, yet this
still doesn't break type safety. It wouldn't necessarily break things if we
did allow the user to discover that it was an xs:NCName. In fact, its most
specific type might even be something like saxon:shortAsciiNCName: functions
are always allowed to return a subtype of the declared type.)
> 
> Implementations are allowed to store the typed value or the 
> string value or 
> both, as node values. What is the result if a basic processor 
> produces a 
> result tree which has typed values stored where one of the 
> instances are the 
> result(as abstract as it is phrased) of a xs:NCName function, 
> and that a 
> Schema aware processor afterwards processes this result tree? 

A basic processor can't produce nodes with any type annotation other than
xdt:untyped or xdt:untypedAtomic. Typed nodes can only be produced by
validation against a schema.

Michael Kay

Received on Friday, 30 September 2005 09:38:39 UTC