xf:date vs xs:date

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

xf:date vs xs:date

mabu
Hi,

According to http://www.w3.org/TR/2001/WD-xforms-20010608/slice4.html there is no difference between the primitive datatype date defined in xml and xforms standard.

If I use Form Builder and insert a date input field I can see in the code that the bind uses the xforms datatype xf:date. But if I want to put a constraint on that field for example . >= xs:date('2010-01-01') I have to use the xml date datatype because otherwise I get the validation error "Invalid XPATH-Expression".

So, is this is a bug or wanted? Is there a difference between these two datatypes? When to use which one?

Martin
Reply | Threaded
Open this post in threaded view
|

Re: xf:date vs xs:date

Alessandro  Vernet
Administrator
Hi Martin,

The difference is that `xf:date` allows for no date to be provided. Without that, you wouldn't be able to have a non-required date field in XForms.

In XPath, to cast a static date to the "date type", I would write `xs:date('2010-01-01')`. And thus if you want to have a constraint on the current field, which is either an `xf:date` or `xs:date`, you can write `, <= xs:date('2010-01-01')`.

Finally, when using Form Builder, you should be shielded from having to know about this ;), and should just be able to add a date field, make it required or not, and if named `my-date` refer to it in XPath expressions as `$my-date`.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: xf:date vs xs:date

mabu
Hi Alex,

Yes, I am using Form Builder and it works fine :)
I was only interested if it is ok to use 'xs:date' in a constraint if the field is 'xf:date'.

Thank you for clarifying.

Martin
Reply | Threaded
Open this post in threaded view
|

Re: xf:date vs xs:date

Alessandro  Vernet
Administrator
Hi Martin, got it, and good!

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet