RE: WD-xpath-functions-20030502: casting xs:QName

At 06:55 AM 10/27/2003, Kay, Michael wrote:

> > i note that the comments period for this document is long
> > over. i note
> > also, however, that it has not yet been supplanted. should
> > the occasion
> > arise to release another version, it would be appropriate for it to
> > address the following:
> >
> > [note please, except for citations, the following discussion uses
> > "universal name" to describe data of the type (namespace-uri X
> > local-part) and "qualified name" to denote data of the type (prefix X
> > local-part). please do try to retain that terminology in your
> > replies -
> > the term "QName" which appears in the document does little to further
> > careful reasoning, as it is meaningless unless qualified.]
>
>The terminology we are trying to use is "lexical QName" for the (prefix, 
>local-name) pair, and "expanded QName" for the (uri, local-name) pair. I 
>agree that we need to be very careful about the distinction and this isn't 
>always true of the current drafts.

The term 'lexical QName' makes sense here, because it means quite literally 
something which matches the production for a QName:

[6]     QName    ::=    (Prefix ':')? LocalPart

When we find one of these names in a query, we can expand the name using 
the URI that is bound to the prefix. The result of this is an 'expanded name'.

These terms seem sensible to me.

> > 17.14 casting to xs:Qname
> >
> > what is the use case for casting from a string to a universal name.
>
>We have decided to remove this functionality, it will disappear in the 
>next draft.

Actually, this is not true. We decided to remove the inverse operation, 
that casts an arbitrary QName to a string, and I think it likely that we 
will need to add this functionality back because we need it to define some 
of our internal operations.

Here's a use case for casting to xs:QName. Suppose I write a function that 
creates an element with a given name:

declare function make-empty-element($n as xs:QName)
     as element()
{
     element { $n } { }
}

Now I want to be able to call this function. Sensibly, my function requires 
a QName for the element name, so it can only be called with this type of 
parameter. Now I want to call this function to create an element named 
"james". To do this, I need to cast a string to a QName:

    let $n := xs:QName("james")
    return make-empty-element( $n )

Hope this helps,

Jonathan 

Received on Thursday, 6 November 2003 10:47:40 UTC