Subject: RE: [xsl] Request help in understanding: node instance of schema-element(node) From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Sun, 27 Jan 2008 21:55:52 -0000 |
> 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"/> > It will also use any schema documents referenced in xsi:schemaLocation if required. > 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. Correct. > > And the stylesheet can check whether validation occurred and > succeeded by using this if-test: > > if (//test instance of schema-element(test)) then ... > > Correct? Yes. > > 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? Well, there are various other things that could go wrong, like there being no test element, or there being more than one, but you're on the right lines. > > The if-test is not requesting the processor perform run-time > validation of the <test> element against the XML Schema. > > Correct? Yes. > > 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' > My preference is to use template rules. Or sometimes I use global variable declarations: <xsl:variable name="test-element" select="/test" as="schema-element(test)"/> which acts as an assertion, causing the stylesheet to fail if not true (provided $test-element is actually referenced, of course). Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Request help in understan, Costello, Roger L. | Thread | [xsl] Accessing file properties, Sean Tiley |
Re: [xsl] combining multiple docume, David Carlisle | Date | [xsl] Group by letter, Rick Quatro |
Month |