Typed datas in XPath2

  • Thread starter Philippe Poulard
  • Start date
P

Philippe Poulard

hi,

consider this :
<foo bar="false"/>

in XPath2
/foo[@bar]
returns my foo element since the bar attribute exists

but if the bar attribute has the type xs:boolean (and that the parser
validates with the appropriate schema and that PSVI augmentation was
set), does the predicate return true() or false() ?

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
 
M

Martin Honnen

Philippe said:
consider this :
<foo bar="false"/>

in XPath2
/foo[@bar]
returns my foo element since the bar attribute exists

but if the bar attribute has the type xs:boolean (and that the parser
validates with the appropriate schema and that PSVI augmentation was
set), does the predicate return true() or false() ?

The "effective boolean value" of @bar with an existing attribute named
'bar' is true, that does not depend on any schema type being available,
that solely depends on whether @bar is an empty sequence or a sequence
where the first item is a node. See
<URL:http://www.w3.org/TR/xpath20/#id-ebv>.
 
P

Philippe Poulard

Martin Honnen a écrit :
Philippe said:
consider this :
<foo bar="false"/>

in XPath2
/foo[@bar]
returns my foo element since the bar attribute exists

but if the bar attribute has the type xs:boolean (and that the parser
validates with the appropriate schema and that PSVI augmentation was
set), does the predicate return true() or false() ?

The "effective boolean value" of @bar with an existing attribute named
'bar' is true, that does not depend on any schema type being available,
that solely depends on whether @bar is an empty sequence or a sequence
where the first item is a node. See
<URL:http://www.w3.org/TR/xpath20/#id-ebv>.

Hi Martin,

I'm afraid that a typed value can't be tested in an intuitive way :
/foo[boolean(@bar)] doesn't work either with the typed value, but with
the EBV rules

What about :
/foo[@bar!=false()]
/foo[@bar!='false']
/foo[data(@bar)]
?

I think the former predicate returns true for the same reason you mentioned
the 2nd returns false since the string value is involved
the latter returns false since the typed value is involved

Right ?

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top