xsl-list
[Top] [All Lists]

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

2006-10-18 05:03:08
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--