[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Challenge: create xPath 2.0 regular expressions fo

Subject: Re: Challenge: create xPath 2.0 regular expressions for each XML Schema datatype
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 18 Oct 2006 13:45:31 +0200
xpath 2.0 regex
Costello, Roger L. wrote:
Hi Folks,

I would like to submit a challenge:

Create xPath 2.0 regular expressions for each of the XML Schema
datatypes.

Examples:

  - the xPath expression which corresponds to integer is:
^\s*[+-]?\d+\s*$

  - the xPath expression which corresponds to float is:
^\s*[+-]?\d+([eE]+?\d+)?\s*$

haha, that was mine. But it is not correct. It supports *only* float/doubles with positive E-notation. For a reason: it was meant to be a float/double that could be parsed as an integer without a loss (remember your flights-altitude?)


For a float, it could be the following:
^\s*[+-]?(\d*\.\d+|\d+\.\d*)([eE][+-]?\d+)?\s*$|^\s*([+-]INF|NaN)\s*$

Note this part: (\d*\.\d+|\d+\.\d*)
It makes sure both ".1" and "1." (which are valid xs:floats) but not "." are allowed.


Note this branch: ^\s*([+-]INF|NaN)\s*$
It is valid to have this in xslt: xs:float('NaN') or xs:float('+INF').

PS: i did not test the regex above, it may contain errors or omissions.
PS2: this regex also applies to xs:double.

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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.