简体   繁体   中英

XSLT Version 2.0 date issue

We are having an issue in regards to our system upgrade. As a result of the upgrade we have to update our XSLT code to ensure its compatible with version XSLT 2.0. The below function worked fine in XSLT 1.0 but no longer functions following the upgrade:

<xsl:if test="ACADEMIC_PROGRAM_START_DATE <= SYSDATE_90">

We can get the function to work if we remove _90 however we need to ensure the criteria is included.

Does anyone have any ideas on how to rewrite this in XSLT version 2.0?

Many thanks

You haven't said whether you're running the code in 1.0-compatible mode, that is, have you changed xsl:stylesheet/@version to say 2.0? If you leave it set to 1.0 then a 2.0 processor interprets this as a request for backwards compatible behaviour.

You also haven't said what's in the two elements ACADEMIC_PROGRAM_START_DATE and SYSDATE_90 that you are comparing. XSLT 1.0 will attempt to treat both values as numeric, whereas XSLT 2.0 will compare them as strings. If you want a numeric comparison, then either run in backwards compatible mode, or convert either or preferably both values to numbers, that is:

xsl:if test="number(ACADEMIC_PROGRAM_START_DATE) <= number(SYSDATE_90)

Alternatively, depending on the format of these elements, it might make more sense to convert them to xs:date values.

Your reference to it working if you drop the "_90" is pretty meaningless unless we know the relationship between elements SYSDATE and SYSDATE_90 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM