xs:string(node()) vs node()/text()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

xs:string(node()) vs node()/text()

Jarosław Kowalewski

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/CAHFpwcVDJU4wJ0OdbDj4wGunYbS8Huj6K4z7d%3Dkuxdu0L%2BERLg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: xs:string(node()) vs node()/text()

Alessandro  Vernet
Administrator
Hi Jarek,

Interesting question. What you are seeing isn't a bug, and is due to the
difference between the typed value and string value of a node (see 1st link
below).

- When calling `xs:string(…)`, e.g. doing a cast (see 2nd link below), the
atomized value of the parameter is taken, and atomization looks at the typed
value of the node. Since the node of type date, the typed value must be a
date, but since in this case it isn't, you have an error, which stops the
evaluation of the expression.
- When you do `$gaga/text()`, you're accessing the text node inside your
element, which will return whatever is stored inside that element irrelevant
of typing.

A very similar situation happens with booleans, which we discuss in the doc
(see 3rd link below), and of course would happen with any other type. This
isn't trivial, or intuitive (maybe unless you already know about it?!), but
hope it will help.

https://www.w3.org/TR/xpath-30/#id-typed-value
https://www.w3.org/TR/xpath-30/#id-cast
https://doc.orbeon.com/form-builder/formulas/formulas-examples#testing-on-a-yes-no-answer-field

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1581360525250-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet