I am looking for suggestions to validate an XML element which holds the date and i need a function in the XSLT to validate whether it is in YYYYMMDD format or not.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You say that you’re using Saxon. If this is the recent version (8.x, 9.x), then it’s an XSLT 2.0 processor, and as such, it supports the
xsl:analyze-stringinstruction for parsing strings using regular expressions, and XML Schema primitive datatypes, includingxs:date. So you can use regex to split date into components, then convert the result to ISO 8601 date, try to convert it toxs:datefor validation of month and day (this should handle leap years etc correctly):