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

Re: [XSLT 2.0] Checking that an element's value has th

Subject: Re: [XSLT 2.0] Checking that an element's value has the desired datatype?
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 17 Oct 2006 13:19:08 +0200
Re:  [XSLT 2.0] Checking that an element's value has th
Costello, Roger L. wrote:
Can you think of a value for the Altitude element that the XSLT template would reject, but a schema validator would accept?

Yes. " 23 "

Good catch! The XSLT expression should be:


matches(flt:Aircraft/flt:Altitude, '^\s*[+\-]?[0-9]+\s$')
You do not need the backslash for the minus sign (end/beginning char class), and I am sure you would want to allow for no spaces at the end. Perhaps this is a little easier to read:

'^\s*[+-]?\d+\s*$'


What about numeric values expressed in exponentional notation? These are (with a side step to xs:double) easily castable as integer. Of course, that should only apply to values that have no decimals (not sure of reqs). If you need it, you can expand your expression so:


matches(flt:Aircraft/flt:Altitude, '^\s*[+-]?\d+([eE]+?\d+)?\s*$')

-- Abel Braaksma

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.