Re: DOM L3 XPath: Multiple matching nodes when number, string or boolean type

On Sat, 2002-02-16 at 19:41, Curt Arnold wrote:
> a) Following the pattern of number() and string() in XPath and
> return the first matching value.
> 
> b) Throw an exception, though it should be distinct from TYPE_ERR.
> 
> c) Separate multiplicity and ordering from the return type parameter
> and have doubleValue, booleanValue, stringValue (and nodeValue for
> node snapshots?) return array types.
> 
> d) Separate multiplicity and ordering from the return type and have
> doubleValue, booleanValue, and stringValue have an index parameter.

If we have the choice, I would pikc the compatiblity with XPath 1.0 and
wait for the XPath folks to define something better before adding it our
module. I don't think it is the role of our API to extend XPath
functionalities.

> Specifically, what should happen if you do:
> 
> XPathResult result = ((XPathEvaluator)
doc).evaluate("/svg/rect/@width",
doc,null, NUMBER_TYPE, null);

as specified in the draft, "the result will be coerced to return the
specified type relying on XPath conversions and fail if the desired
coercion is not possible.". So you'll convert into a number as defined
in:
http://www.w3.org/TR/1999/REC-xpath-19991116#function-number

I guess adding a link from the constant NUMBER_TYPE to the function
number could help.

> However, I don't believe the scenario is adequately addressed in
> the current draft.  My initial leaning would be toward option c,
> however I would assume that array types are avoided intentionally
> in the DOM.

I don't remember discussions on array types in the group but that might
have happened before 1999. Anyway, I don't think we should diverge from
the XPath specification.

Philippe

Received on Tuesday, 19 February 2002 18:35:49 UTC