Subject: [xsl] Different Behavior for Regex in XSD and XSLT/XQuery From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 10 Jan 2018 16:15:10 -0000 |
I have this simple type in an XSD, which is my attempt to validate strings that are subsets of the string representation of xs:time values: <xs:simpleType name="timestr"> <xs:restriction base="xs:string"> <xs:pattern value="(\d|0\d|1\d|2[0123])(:([0-5]\d|60)(:([0-5]\d|60))?)?|24(:00(:00)?)?"/> </xs:restriction> </xs:simpleType> And it correctly rejects "05:96" as invalid. However, using the same regex with start/end anchors added in matches() it does not reject "05:96". This transform: <xsl:template match="/"> <xsl:variable name="timestr" as="xs:string" select="'05:96'" /> <xsl:variable name="is-valid" as="xs:boolean" select="matches($timestr, '^(\d|0\d|1\d|2[0123])(:([0-5]\d|60)(:([0-5]\d|60))?)?|24(:00(:00)?)?$')" /> <result> <is-valid><xsl:value-of select="$timestr"/>, <xsl:value-of select="$is-valid"/></is-valid> </result> </xsl:template>o;? Produces: <result><is-valid>05:96, true</is-valid></result>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] That's a wrap!, Graydon graydon@xxxx | Thread | Re: [xsl] Different Behavior for Re, David Carlisle d.p.c |
Re: [xsl] That's a wrap!, Charles O'Connor coc | Date | Re: [xsl] Different Behavior for Re, David Carlisle d.p.c |
Month |