date format handling

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

date format handling

Gerrit Germis-2
Hi all,

I have a rather daft question, but I don't seem to be able to figure it
out. We have an input XML instance that is supplied by our customer.
This instance contains date fields of the format YYYYMMDD. These dates
should be editable, so I defined an xforms:bind tag like:

  <xforms:bind nodeset="instance('data')//datefield" type="xs:date"/>

However, the xs:date expects the date to be in the format YYYY-MM-DD.
How can I convert back and forth between these two date formats? The
date stored in the XML should be YYYYMMDD

This is the inputfield I use:

  <xforms:input ref="instance('data')/somewhere/datefield"
    xxforms:format="format-date(xs:date(.), '[Y]-[M01]-[D01]', 'en', (),
())"/>

This shows the date as YYYY-MM-DD to the user (which is as it should
be), but also saves it in that format to the XML (but I want it as
YYYYMMDD in the XML).

There are a number of date-fields like this in my form, most of them in
detail lines of an invoice (from/to) which can be dynamically added, so
simply copying the value to another instance doesn't seem to be an
option for me (unless I'm not seeing the obvious of course)

Could anyone please help me out with this issue?

Thanks in advance,
Sincerely,
Gerrit


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: date format handling

StephR
Couldn't you do the formatting in a xslt processor before sending it to the database?

Gerrit Germis a écrit :
Hi all,

I have a rather daft question, but I don't seem to be able to figure it
out. We have an input XML instance that is supplied by our customer.
This instance contains date fields of the format YYYYMMDD. These dates
should be editable, so I defined an xforms:bind tag like:

  <xforms:bind nodeset="instance('data')//datefield" type="xs:date"/>

However, the xs:date expects the date to be in the format YYYY-MM-DD.
How can I convert back and forth between these two date formats? The
date stored in the XML should be YYYYMMDD

This is the inputfield I use:

  <xforms:input ref="instance('data')/somewhere/datefield"
    xxforms:format="format-date(xs:date(.), '[Y]-[M01]-[D01]', 'en', (),
())"/>

This shows the date as YYYY-MM-DD to the user (which is as it should
be), but also saves it in that format to the XML (but I want it as
YYYYMMDD in the XML).

There are a number of date-fields like this in my form, most of them in
detail lines of an invoice (from/to) which can be dynamically added, so
simply copying the value to another instance doesn't seem to be an
option for me (unless I'm not seeing the obvious of course)

Could anyone please help me out with this issue?

Thanks in advance,
Sincerely,
Gerrit
  


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: date format handling

Gerrit Germis-2
In reply to this post by Gerrit Germis-2

Hi Stephane,

 

Thanks for the swift response.

 

XSLT could indeed be an option to consider. I would have to convert to YYYY-MM-DD before loading into the instance data, and convert back to YYYYMMDD before saving the results to file. I was hoping for a bit less work/maintenance intensive approach (stylesheet for every type of invoice per customer), but it could certainly be an option. Wouldn’t it be possible to create a custom xs:date datatype and override the pattern somehow?

 

Thanks again,

 

Sincerely,

Gerrit

 

 


From: Stephane Ruchet [mailto:[hidden email]]
Sent: Saturday, November 24, 2007 14:15 PM
To: [hidden email]
Subject: Re: [ops-users] date format handling

 

Couldn't you do the formatting in a xslt processor before sending it to the database?

Gerrit Germis a écrit :

Hi all,
 
I have a rather daft question, but I don't seem to be able to figure it
out. We have an input XML instance that is supplied by our customer.
This instance contains date fields of the format YYYYMMDD. These dates
should be editable, so I defined an xforms:bind tag like:
 
  <xforms:bind nodeset="instance('data')//datefield" type="xs:date"/>
 
However, the xs:date expects the date to be in the format YYYY-MM-DD.
How can I convert back and forth between these two date formats? The
date stored in the XML should be YYYYMMDD
 
This is the inputfield I use:
 
  <xforms:input ref="instance('data')/somewhere/datefield"
    xxforms:format="format-date(xs:date(.), '[Y]-[M01]-[D01]', 'en', (),
())"/>
 
This shows the date as YYYY-MM-DD to the user (which is as it should
be), but also saves it in that format to the XML (but I want it as
YYYYMMDD in the XML).
 
There are a number of date-fields like this in my form, most of them in
detail lines of an invoice (from/to) which can be dynamically added, so
simply copying the value to another instance doesn't seem to be an
option for me (unless I'm not seeing the obvious of course)
 
Could anyone please help me out with this issue?
 
Thanks in advance,
Sincerely,
Gerrit
  


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: date format handling

Jozef Aerts - XML4Pharma
The alternative may be to have a "hidden" field, that uses "calculate", something like:
 
<xforms:bind nodeset="/form/date-non-ISO" calculate="replace(/form/date-ISO,'-','')" />
 
(did not try this out though),
and on the server, store the value from date-non-ISO to the database.
----- Original Message -----
Sent: Saturday, November 24, 2007 2:57 PM
Subject: RE: [ops-users] date format handling

Hi Stephane,

 

Thanks for the swift response.

 

XSLT could indeed be an option to consider. I would have to convert to YYYY-MM-DD before loading into the instance data, and convert back to YYYYMMDD before saving the results to file. I was hoping for a bit less work/maintenance intensive approach (stylesheet for every type of invoice per customer), but it could certainly be an option. Wouldn’t it be possible to create a custom xs:date datatype and override the pattern somehow?

 

Thanks again,

 

Sincerely,

Gerrit

 

 


From: Stephane Ruchet [mailto:[hidden email]]
Sent: Saturday, November 24, 2007 14:15 PM
To: [hidden email]
Subject: Re: [ops-users] date format handling

 

Couldn't you do the formatting in a xslt processor before sending it to the database?

Gerrit Germis a écrit :

Hi all,
 
I have a rather daft question, but I don't seem to be able to figure it
out. We have an input XML instance that is supplied by our customer.
This instance contains date fields of the format YYYYMMDD. These dates
should be editable, so I defined an xforms:bind tag like:
 
  <xforms:bind nodeset="instance('data')//datefield" type="xs:date"/>
 
However, the xs:date expects the date to be in the format YYYY-MM-DD.
How can I convert back and forth between these two date formats? The
date stored in the XML should be YYYYMMDD
 
This is the inputfield I use:
 
  <xforms:input ref="instance('data')/somewhere/datefield"
    xxforms:format="format-date(xs:date(.), '[Y]-[M01]-[D01]', 'en', (),
())"/>
 
This shows the date as YYYY-MM-DD to the user (which is as it should
be), but also saves it in that format to the XML (but I want it as
YYYYMMDD in the XML).
 
There are a number of date-fields like this in my form, most of them in
detail lines of an invoice (from/to) which can be dynamically added, so
simply copying the value to another instance doesn't seem to be an
option for me (unless I'm not seeing the obvious of course)
 
Could anyone please help me out with this issue?
 
Thanks in advance,
Sincerely,
Gerrit
  



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: date format handling

Erik Bruchez
Administrator
In reply to this post by Gerrit Germis-2
Gerrit,

I think the responses that have been made in this thread all make sense.

I guess it would make sense at some point to either have an XForms  
extension allowing translating values from a form control to the data,  
or (and maybe even better) the component system [1] we hope to have at  
some point could allow form authors to define their own translation at  
the component level.

-Erik

[1] https://wiki.objectweb.org/ops/Wiki.jsp?page=XFormsComponents

On Nov 24, 2007, at 4:42 AM, Gerrit Germis wrote:

> Hi all,
>
> I have a rather daft question, but I don't seem to be able to figure  
> it
> out. We have an input XML instance that is supplied by our customer.
> This instance contains date fields of the format YYYYMMDD. These dates
> should be editable, so I defined an xforms:bind tag like:
>
>  <xforms:bind nodeset="instance('data')//datefield" type="xs:date"/>
>
> However, the xs:date expects the date to be in the format YYYY-MM-DD.
> How can I convert back and forth between these two date formats? The
> date stored in the XML should be YYYYMMDD
>
> This is the inputfield I use:
>
>  <xforms:input ref="instance('data')/somewhere/datefield"
>    xxforms:format="format-date(xs:date(.), '[Y]-[M01]-[D01]', 'en',  
> (),
> ())"/>
>
> This shows the date as YYYY-MM-DD to the user (which is as it should
> be), but also saves it in that format to the XML (but I want it as
> YYYYMMDD in the XML).
>
> There are a number of date-fields like this in my form, most of them  
> in
> detail lines of an invoice (from/to) which can be dynamically added,  
> so
> simply copying the value to another instance doesn't seem to be an
> option for me (unless I'm not seeing the obvious of course)
>
> Could anyone please help me out with this issue?
>
> Thanks in advance,
> Sincerely,
> Gerrit
>
> --
> You receive this message as a subscriber of the [hidden email]  
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws