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

Subject: RE: [xsl] Request help in understanding: node instance of schema-element(node)
From: "Costello, Roger L." <costello@xxxxxxxxx>
Date: Sun, 27 Jan 2008 14:32:36 -0500
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

Current Thread