matching elements by name and type to detect invalid
I know I moaned about input validation the other day but I hadn't come across this: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:import-schema> <xs:schema> <xs:complexType name="root"> <xs:sequence> <xs:element name="child" /> </xs:sequence> </xs:complexType> </xs:schema> </xsl:import-schema> <xsl:template match="element(root, root)"> <xsl:value-of select="wrong" /> </xsl:template> </xsl:stylesheet> Compile that with a schema-aware processor (Saxon SA in this case) and you are told: "The complex type root does not allow a child element named wrong;" You don't even have to validate any input, because the match pattern contains the type it knows that "wrong" is not a child of <root>... fantastic :) I think this means you can enjoy the benefits of the paths in your XSLT being checked against the schema _without_ being forced to validate the input each time... which is a huge benefit. (sorry if you were well aware of this already) -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format