[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Request help in understanding: node instance of

Subject: RE: Request help in understanding: node instance of schema-element(node)
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 26 Jan 2008 22:55:56 -0000
RE:  Request help in understanding:  node instance of
> 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/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.