Subject: Re: [xsl] Is an XPath processor responsible for catching misspelled tag names when there is an associated Schema? From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Thu, 21 Feb 2008 16:33:56 +0000 |
On 21/02/2008, Michael Kay <mike@xxxxxxxxxxxx> wrote: > 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). Here's a little example to demonstrate that: <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:import-schema> <xs:schema> <xs:element name="shapes" type="shapes"/> <xs:element name="shape" type="xs:string"/> <xs:complexType name="shapes"> <xs:sequence> <xs:element ref="shape"/> </xs:sequence> </xs:complexType> </xs:schema> </xsl:import-schema> <xsl:variable name="input" as="schema-element(shapes)"> <shapes xsl:type="shapes"> <shape>Hello</shape> </shapes> </xsl:variable> <xsl:template match="/" name="main"> <xsl:value-of select="$input/shap"/> </xsl:template> </xsl:stylesheet> The xsl:import-schema element defines the schema for the input, and the $input variable contains some XML that gets typed by that schema using the xsl:type attribute. In the main template the value-of select is deliberately misspelt, which results in the following warning: "The complex type shapes does not allow a child element named shap" ...which is great :) -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Is an XPath processor res, Michael Kay | Thread | [xsl] Variables and more than one d, White, Clinton |
Re: [xsl] Complex recursion in XSLT, Florent Georges | Date | Re: [xsl] Complex recursion in XSLT, Manfred Staudinger |
Month |