checking date
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 2
- Joined: Sat Jul 07, 2007 5:05 pm
checking date
How do you do a date comparison?
if Ihave something like:
<xsl:value-of select="format-number(sum($something[ xyz ... ]
where xyz is checking the value of some variable like "valid=y", and I want to extend that check to say "if valid = y and date > 1 Jan 2007" how do I do it?
Should something like this work?
date > '01-Jan-2007' ?
date is coming from a sybase table.
Many thanks,
Mike
if Ihave something like:
<xsl:value-of select="format-number(sum($something[ xyz ... ]
where xyz is checking the value of some variable like "valid=y", and I want to extend that check to say "if valid = y and date > 1 Jan 2007" how do I do it?
Should something like this work?
date > '01-Jan-2007' ?
date is coming from a sybase table.
Many thanks,
Mike
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
Yes, the > and < operators are correct but I suggest to compare values of type xs:date available in XSLT 2.0 which have the format YYYY-MM-DD. If you use a constant value and a node date then a test like
will work but if you use two nodes then you have to convert to xs
Regards,
Sorin
Yes, the > and < operators are correct but I suggest to compare values of type xs:date available in XSLT 2.0 which have the format YYYY-MM-DD. If you use a constant value and a node date then a test like
Code: Select all
date > 2007-01-01
Code: Select all
xs:date(date1) > xs:date(date2)
Regards,
Sorin
-
- Posts: 2
- Joined: Sat Jul 07, 2007 5:05 pm
Many thanks for your reply. I will try this, I tried it in some other variations but not with the xs:date().
i found some functions like format-dateTime but I couldnt get them to work. Do they require a "xs:" constuct? What is that doing actually, is it specifying the namespace where the function date() is to be found?
Regards,
Mike
i found some functions like format-dateTime but I couldnt get them to work. Do they require a "xs:" constuct? What is that doing actually, is it specifying the namespace where the function date() is to be found?
Regards,
Mike
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Yes, the xs: prefix is for the namespace http://www.w3.org/2001/XMLSchema where the date type is defined. You have to associate the prefix to the namespace in the stylesheet before using the prefix, for example on the root element:
Regards,
Sorin
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0">
Regards,
Sorin
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