Re: [F&O] Casting to xs:NOTATION, xs:QName not clarified

Michael Rys wrote:
>>That aside, a quick question... I have been looking at the spec for a
>>little while to find a way to resolve an xs:string, containing an
>>XPath query, to a nodeset... Does anyone know how to achieve that? :)
> 
> By means of some non-standardized mechanism. :-)

Right. Wouldn't it be a good idea to create a standardized mechanism for 
this?

My current use case:

<input type="text" value="//p" />
<button b:action="alert" b:value="{count(getnode(/input/@value))}">
     Count nodes
</button>

The idea is that the user has an input field, which he can fill in with 
an XPath query (this input is reflected back into the DOM), and then 
click on a button called 'count'. This should pop up an alert box which 
contains the nr. of matches for the given XPath query. But, for that we 
need some function or cast which evaluates the string retrieved from the 
value attribute as an XPath query.

Now we could implement our own syntax for this. But then again, we could 
not, if there were to be a standard mechanism for this (it doesn't seem 
that uncommon a thing to want to do, does it?). Maybe node() could be 
given an optional parameter?


Ashok Malhotra wrote:
>>What confuses me is, that in the 'Status of this Document' section of
>>XQuery 1.0 and XPath 2.0 Functions and Operators, it says:
>>
>>"Some of the more significant changes that appear in this version of
>>the document are:
>>
>>     * Casting to QName and xs:NOTATION has been clarified. It is now
>>possible to cast from xs:string literals to QName and xs:NOTATION."
>
> That was a bug in the status section.  It now says...
> 
> "Construction of xs:QNames and types derived from xs:NOTATIONs has
> been clarified. It is now possible to construct xs:QNames and types
> derived from xs:NOTATIONs from xs:string literals."

Right, so the xs:QName("a") example Frank Legler gave is possible, but 
it's not possible to e.g. do xs:QName(text()), or to cast it.


~Grauw

-- 
Ushiko-san! Kimi wa doushite, Ushiko-san!!

Received on Tuesday, 18 January 2005 01:18:31 UTC