xsl-list
[Top] [All Lists]

RE: [xsl] Is an XPath processor responsible for catching misspelled tag names when there is an associated Schema?

2008-02-21 07:54:17
You haven't shown the full context of your stylesheet/xpath expression.

The processor can't assume that because an element is named Book that it
will be a valid instance of the global element declaration Book in the
schema. It might for example be a temporary unvalidated element, and it's
perfectly legitimate to mix validated/valid trees and unvalidated/invalid
trees in the same program.

The XQuery/XPath formal semantics define an optional feature called "static
typing" that guarantees that if the type of $b is known to be
schema-element(Book), then $b/autr is a static type error. But static typing
unfortunately can reject many perfectly reasonable expressions as well, so
many products including Saxon choose not to implement it.

Saxon will give you a compile time warning for this situation. However, if
there is no static type information available, then it can't do this. To get
maximum benefit from schema-aware processing, you should declare the types
of your variables and function parameters (and especially, the type of the
principal input). 


QUESTIONS

1. Is it the responsibility of a schema-aware processor to 
catch misspelled tag names in XPath expressions?

Yes, provided (a) the type of the context of the path is known, and (b) the
processor implements static typing.

2. Is there a flag that I can set in SAXON to tell it to 
catch such misspelling errors?

You should declare the types of your variables and parameters as accurately
as you can.

The scope for this in freestanding XPath with Saxon is limited; if you want
this it's probably best to process your XPath expressions with the XQuery
processor.

Michael Kay
http://www.saxonica.com/


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