andrewjwelch.com
schema-aware.com
schema-aware XSLT and XQuery examples
SAXONICA

"hello world" - result validation using the xsl:valation attribute

Validating the result using xsl:validation attribute.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="2.0">
    
    
<xsl:import-schema namespace="http://www.w3.org/1999/xhtml" schema-location="http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd" />
    
    
<xsl:template match="/">

        
<html xsl:validation="strict">
            
<head>
                
<title>Schema Aware XSLT example</title>
            
</head>
            
<body>
                
<div>Hello World</div>
            
</body>
        
</html>

    
</xsl:template>   
    
</xsl:stylesheet>
Validation is invoked by the xsl:validation attribute on the <html> literal result element. The allowed values are strict, lax, preserve or strip. In this case its "strict" which means the element must be validated and its an error if a definition cannot be found.