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
--~------------------------------------------------------------------
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>
--~--