[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: "Costello, Roger L." <costello@xxxxxxxxx>
Date: Mon, 16 Oct 2006 19:25:01 -0400
RE:  [XSLT 2.0] Checking that an element's value has th
Hi Folks,

Consider this XML document again:

<?xml version="1.0"?>
<Flight xmlns="http://www.aviation.org">
    <Aircraft>
        <Altitude>3300</Altitude>
    </Aircraft>
</Flight>

Suppose that we want a mechanism to check that the value of the
Altitude element is an integer.

The mechanism should accept all of these as valid values:

<Altitude>3300</Altitude>
<Altitude>0</Altitude>
<Altitude>-53</Altitude>

The mechanism should reject all of these as invalid values:

<Altitude>XYZ</Altitude>
<Altitude>66.01</Altitude>
<Altitude>true</Altitude>

One mechanism is to create an XML Schema and declare Altitude as such:

<element name="Altitude" type="integer"/>

The above valid values would be accepted by a schema validator.  The
invalid values would be rejected by a schema validator.

Now consider this XSLT template:

<xsl:template match="flt:Flight">
      <xsl:choose>
            <xsl:when test="matches(flt:Aircraft/flt:Altitude,
'^[+-]?[0-9]+$')">
                  ACCEPTED: Altitude has a valid value
            </xsl:when>
            <xsl:otherwise>
                  REJECTED: Altitude has an invalid value
            </xsl:otherwise>
      </xsl:choose>
</xsl:template>

The above valid values would be accepted by the XSLT template.  The
invalid values would be rejected by the XSLT template.

QUESTION: can you think of a value for the Altitude element that the
XSLT template would accept, but a schema validator would reject?  Can
you think of a value for the Altitude element that the XSLT template
would reject, but a schema validator would accept?

Thanks!

/Roger

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.