xsl-list
[Top] [All Lists]

RE: [xsl] Request help in understanding: node instance of schema-element(node)

2008-01-27 12:33:07
Michael Kay wrote:

You haven't shown the bit that you did wrong, which was almost
certainly to
run the stylesheet against an unvalidated input document. With Saxon,
you
request validation by using an option on the command line (-val for
8.9.0.4,
-val:strict for 9.0.0.n) 

Thanks Michael.  You are correct, after adding the -val option my
if-then-else statement performed as desired.

So, as I understand it, by adding the -val option SAXON validates the
XML input document against the XML Schema specified by the stylesheet:

   <xsl:import-schema schema-location="test.xsd"/>

Correct?

If validation fails, SAXON throws an error and aborts processing. 

If validation succeeds, then the stylesheet can be certain that the
<test> element in the input document conforms to the test element
declaration in the XML Schema.

And the stylesheet can check whether validation occurred and succeeded
by using this if-test:

   if (//test instance of schema-element(test)) then ...

Correct?

Thus, if the processor does not abort and the if-test fails it means:

-- The input XML document was not validated against the XML Schema.

There is no other reason for the if-test failing.

Correct?

The if-test is not requesting the processor perform run-time validation
of the <test> element against the XML Schema.

Correct?

Do these comments correctly describe the state of affairs:

   if (//test instance of schema-element(test)) then
       (: the <test> element is what's expected, so operate on it :)
   else
       {: the <test> element may or may not be what's expected; proceed
with caution :)


Is this the proper way to check <test> before operating on it?

   if (//test instance of schema-element(test)) then
       //test * 2
   else
       if (//test castable as xs:integer) then
           //test * 2
       else
           'Error'


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