|
Subject: Re: [xsl] Request help in understanding: node instance of schema-element(node) From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx> Date: Sun, 27 Jan 2008 13:02:04 +0530 |
Hi Mike,
Though I don't doubt very much the reasons behind the current
Schema awareness design in the XSLT 2.0 spec.
But I have a personal curiosity, related to Roger's question in this thread.
I would have preffered a syntax
<xsl:value-of select="if (//test instance of
schema-element(test)) then
//test * 2
else 'Error'"/>
Without doing, <xsl:import-schema schema-location="test.xsd"/> in the
2.0 stylesheet.
(I think, having the declaration, <xsl:import-schema
schema-location="test.xsd"/> in stylesheet provides static
availability of type information, without having dynamic introspection
from PSVI - which I probably like).
The XSLT 2.0 processor should be able to get type information from
Schema, after the validation event (either by -val / -val:strict
options, or from the xsi:schemaLocation attribute in the instance
document). Does Saxon-SA support xsi:schemaLocation method as well
(and I don't do -val / -val:strict) ? If Saxon doesn't support
xsi:schemaLocation method, my curiosity is, why not?
On Jan 27, 2008 4:25 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> >
> > Apparently I am not correctly understanding this XPath statement:
> >
> > if (//test instance of schema-element(test)) then
> > //test * 2
> > else 'Error'
> >
> > My understanding of the XPath is this: "If the <test> element
> > in the input document conforms to the declaration of test in
> > the XML Schema then multiply its value by 2, otherwise output Error."
>
> See my XPath 2.0 Programmer's Reference page 287 regarding "instance of":
>
> "It's important to remember, whether you are testing atomic values or nodes,
> that the "instance of" operator is testing whether the value has a label
> that identifies it as a member of the specified type. It isn't testing
> whether the value would be a valid member of that type if the label were
> changed."
>
> It goes on:
>
> "the fact that validation against this type would succeed is not enough; the
> validation must actually have been done, so that the required type
> annotation is present on the node."
>
> This is not that dissimilar from other languages: in Java, ("2008-01-25"
> instanceof Date) returns false.
> >
> > What am I doing wrong?
> >
> > I am using the schema-aware version of SAXON, version
> > 8.9.0.4j. Below is the stylesheet, XML Schema, and XML document.
> >
> 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) (or of course via the Java API). With Altova, you
> request validation by including an xsi:schemaLocation attribute in the
> instance document.
>
> Michael Kay
> http://www.saxonica.com/
--
Regards,
Mukul Gandhi
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Request help in understan, Michael Kay | Thread | Re: [xsl] Request help in understan, Colin Paul Adams |
| Re: [xsl] manage errors and termina, Colin Paul Adams | Date | Re: [xsl] Request help in understan, Colin Paul Adams |
| Month |