Re: [xsl] Challenge: create xPath 2.0 regular expressions for each XML Schema datatype

Subject: Re: [xsl] Challenge: create xPath 2.0 regular expressions for each XML Schema datatype
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 18 Oct 2006 14:02:29 +0200
David Carlisle wrote:
Most of those are already listed in the schema spec eg
http://www.w3.org/TR/xmlschema-2

    <xs:restriction base="xs:short">
      <xs:minInclusive value="-128" id="byte.minInclusive"/>
      <xs:maxInclusive value="127" id="byte.maxInclusive"/>

tells you immediately that the xpath2 for byte is

(:whatever you have for xs:short:) and $value >= -128 and $value <= 127

But he was thinking of a regular expression. Though it seems a bit outrageous to create a regex for a byte, it might look something like this:


regex = "^\s*(([+-]?(1[01]\d|12[0-7]|0?\d?\d))|+?128)\s*$"

Note that this regex does not allow for an empty string (which is correct, as xs:byte('') would fail)

-- Abel Braaksma
  http://www.nuntia.com

Current Thread