Re: [xsl] [XSLT 2.0] Checking that an element's value has the desired datatype?

Subject: Re: [xsl] [XSLT 2.0] Checking that an element's value has the desired datatype?
From: "bryan rasmussen" <rasmussen.bryan@xxxxxxxxx>
Date: Tue, 17 Oct 2006 13:34:57 +0200
Well sure, in a sense. One thing that Schematron, even 1.5 version can
do that the other ones can't is algorithmic checking of types. We very
seldomly want to just check that something is a number, we want to
check that it is a number that returns a true after a modulus 10 check
for example.

Schematron does not do grammatical checks well (I think everyone will
agree on this, I would not want to represent all of a document's
grammar with Schematron - even though I am on a project where we have
done this because of.... well I won't say why)

also Schematron with XPath 2.0, not sure how easy it is to optimize as
opposed to XML Schema (not by writers but by implementors) I had this
same conversation with Noah Mendelsohn sometime last year I think were
he argues that they had an extremely fast Schema implementation and he
was not sure how well it could be translated to Schematron (he was not
well acquainted with Schematron) the conversation started somewhere
around here http://lists.w3.org/Archives/Public/xmlschema-dev/2005Nov/0032.html
-


Cheers, Bryan Rasmussen

On 10/17/06, Costello, Roger L. <costello@xxxxxxxxx> wrote:
> As stated earlier I don't believe he wants to get the type, he wants
> to constrain the value,  and as for me I am not at all interested in
> the type.

Exactly right. Thanks Bryan.

I sense that ya'll are wondering where I am going with this?

Schematron + xPath 2.0 is extremely powerful.  In fact, one could argue
that it can do everything that XML Schema (or RelaxNG) can do, plus a
lot more.

For example, below is an XML document showing information about an
aircraft and vertical obstructions on its flight path.  One critical
operational constraint is:

"Check that the aircraft's altitude is at least 500 feet above all the
vertical obstructions"

This "co-constraint" cannot be expressed using XML Schemas (or
RelaxNG).

But with Schematron + xPath 2.0 the co-constraint can be expressed
using this xPath:

every $j in flt:VerticalObstruction satisfies if ($j/flt:Height) then
number(flt:Aircraft/flt:Altitude) gt number($j/flt:Height +
$j/flt:Elevation + 500) else number(flt:Aircraft/flt:Altitude) gt
number($j/flt:Elevation + 500)

As best I can tell, the functionality of Schematron + xPath 2.0 is a
superset of XML Schemas (and RelaxNG).  However, I am still researching
this.  The findings in this discussion will be incorporated into a
paper I am writing.

I appreciate all your input. /Roger

<?xml version="1.0"?>
<Flight xmlns="http://www.aviation.org";>
   <Aircraft type="Boeing 747">
       <Altitude units="feet" reference="MSL">3300</Altitude>
       <Location>
           <Latitude>42.371</Latitude>
           <Longitude>-71.000</Longitude>
       </Location>
   </Aircraft>
   <VerticalObstruction type="tower">
       <!-- The top of the tower is 1500 feet -->
       <Elevation units="feet">1000</Elevation>
       <Height units="feet">500</Height>
       <Location>
           <Latitude>42.371</Latitude>
           <Longitude>-71.025</Longitude>
       </Location>
   </VerticalObstruction>
   <VerticalObstruction type="mountain">
       <Elevation units="feet">2600</Elevation>
       <Location>
           <Latitude>42.371</Latitude>
           <Longitude>-71.155</Longitude>
       </Location>
   </VerticalObstruction>
   <VerticalObstruction type="building">
       <!-- The top of the building is 700 feet -->
       <Elevation units="feet">500</Elevation>
       <Height units="feet">200</Height>
       <Location>
           <Latitude>42.371</Latitude>
           <Longitude>-71.299</Longitude>
       </Location>
   </VerticalObstruction>
</Flight>

Current Thread