xsl-list
[Top] [All Lists]

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

2006-10-17 02:15:45
On 10/17/06, Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:
> I think people have forgotten the explicit reference Roger
> made to schematron, since schematron is a validation
> technology that can be implemented in XSL-T it follows that
> the expression matches(flt:Aircraft/flt:Altitude, '[0-9]+')
> would give you the same capabilities as XML Schema datatype
> checking in any actually useful scenario.

I think you're missing the point that schema-aware processing does much more
than run-time input validation. For example, it gives you compile time error
messages if you use the wrong kind of argument to a function or operator.
See my article http://www.stylusstudio.com/schema_aware.html for background
and some examples. You really have to try it out to develop a real complex
stylesheet to see the benefits - it's remarkable how much faster you can
find your bugs. Honest.

I'm with Bryan on this one - whether he validates the Altitude as
xs:integer with the schema or tries to create an xs:integer out of the
value in the transform the result will be the same - except it will be
caught in two different places.

I don't understand why defining it in a schema would be any better -
in this case.  Maybe I'm being naive.  If "xs:integer(Altitude)" or
"Altitude castable as xs:integer" returns true, then the receiving
application that expects integers should be happy.  If the values are
meant for display, then checking they are integers wont be sufficient,
but thats a different requirement.

I should point out that Im all for schema aware transforms -
expecially validating the result as its created - its a truly
satisfying experience for anyone who did a lot of 1.0.  However, in
this case, I dont see how typing the input as xs:integer would be any
better/different to creating an xs:integer out of the value in the
transform.

cheers
andrew

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

<Prev in Thread] Current Thread [Next in Thread>