How do I convert a string variable date into a date?
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 62
- Joined: Thu Jun 26, 2014 9:00 pm
How do I convert a string variable date into a date?
I have a xslt which is using a xml document. The xml document has a variable dateServed="06/20/2014". When I run the xslt, I get error FORG0001: Cannot conver xs:string with value '06/20/2014' to xs:date.
What do I need to do to convert this dateServed="06/20/2014" to a date?
What do I need to do to convert this dateServed="06/20/2014" to a date?
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: How do I convert a string variable date into a date?
Hi,
xs:date expects the date to be in format yyyy-mm-dd, so you just have to adjust it to that format with the help of string functions.
There is an example showing this on stack overflow:
http://stackoverflow.com/questions/1685 ... n-xslt-2-0
Regards,
Adrian
xs:date expects the date to be in format yyyy-mm-dd, so you just have to adjust it to that format with the help of string functions.
There is an example showing this on stack overflow:
http://stackoverflow.com/questions/1685 ... n-xslt-2-0
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 62
- Joined: Thu Jun 26, 2014 9:00 pm
Re: How do I convert a string variable date into a date?
I am still confused as to how to do this.
I have the following from xsl
So how do I convert this date string to date?
I have the following from xsl
Code: Select all
<NotificationEvent dateServed="06/20/2014"</NotificationEvent>
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: How do I convert a string variable date into a date?
For creating an xs:date (yyyy-mm-dd) from dateServed='mm/dd/yyyy':
Code: Select all
<xsl:variable name="date" select="xs:date(concat(
substring(@dateServed,7,4),'-',
substring(@dateServed,1,2),'-',
substring(@dateServed,4,2)))"/>
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service