title: Strict compilation of XSLT, but without validating the input XML on application
body: <p>I have a schema (as per previous questions, but this time it has some &quot;required&quot; attributes on FILLEDSQUARETYPE).</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;xs:schema xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; elementFormDefault=&quot;qualified&quot;
      xmlns:vc=&quot;http://www.w3.org/2007/XMLSchema-versioning&quot; vc:minVersion=&quot;1.1&quot;&gt;
  
    &lt;xs:complexType name=&quot;SQUARETYPE&quot;&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name=&quot;contains&quot;&gt;
          &lt;xs:complexType&gt;
            &lt;xs:choice minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;&gt;
              &lt;xs:element ref=&quot;SQUARE&quot;/&gt;
              &lt;xs:element ref=&quot;TRIANGLE&quot;/&gt;
            &lt;/xs:choice&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name=&quot;kind&quot;/&gt;
      &lt;xs:attribute name=&quot;width&quot; type=&quot;xs:int&quot;/&gt;
      &lt;xs:attribute name=&quot;x&quot; type=&quot;xs:int&quot;/&gt;
      &lt;xs:attribute name=&quot;y&quot; type=&quot;xs:int&quot;/&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:complexType name=&quot;FILLEDSQUARETYPE&quot;&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name=&quot;contains&quot;&gt;
          &lt;xs:complexType&gt;
            &lt;xs:choice minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;&gt;
              &lt;xs:element ref=&quot;SQUARE&quot;/&gt;
              &lt;xs:element ref=&quot;TRIANGLE&quot;/&gt;
            &lt;/xs:choice&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name=&quot;kind&quot;/&gt;
  
      &lt;xs:attribute name=&quot;colour&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
      &lt;xs:attribute name=&quot;width&quot; type=&quot;xs:int&quot;  use=&quot;required&quot;/&gt;
      &lt;xs:attribute name=&quot;x&quot; type=&quot;xs:int&quot;  use=&quot;required&quot;/&gt;
      &lt;xs:attribute name=&quot;y&quot; type=&quot;xs:int&quot;  use=&quot;required&quot;/&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:complexType name=&quot;TRIANGLETYPE&quot;&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name=&quot;contains&quot;&gt;
          &lt;xs:complexType&gt;
            &lt;xs:choice minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;&gt;
              &lt;xs:element ref=&quot;SQUARE&quot;/&gt;
              &lt;xs:element ref=&quot;TRIANGLE&quot;/&gt;
            &lt;/xs:choice&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name=&quot;rotation&quot; type=&quot;xs:int&quot;/&gt;
      &lt;xs:attribute name=&quot;x&quot; type=&quot;xs:int&quot;/&gt;
      &lt;xs:attribute name=&quot;y&quot; type=&quot;xs:int&quot;/&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:element name=&quot;SQUARE&quot;&gt;
      &lt;xs:alternative test=&quot;@kind = 'FILLEDSQUARETYPE'&quot; type=&quot;FILLEDSQUARETYPE&quot;/&gt;
      &lt;xs:alternative test=&quot;@kind = 'SQUARETYPE'&quot; type=&quot;SQUARETYPE&quot;/&gt;
      &lt;xs:alternative type=&quot;xs:error&quot;/&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name=&quot;TRIANGLE&quot;&gt;
      &lt;xs:alternative type=&quot;TRIANGLETYPE&quot;/&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name=&quot;rootShape&quot;&gt;
      &lt;xs:complexType&gt;
        &lt;xs:choice minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;&gt;
          &lt;xs:element ref=&quot;SQUARE&quot;/&gt;
          &lt;xs:element ref=&quot;TRIANGLE&quot;/&gt;
        &lt;/xs:choice&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  <p>I have an XSLT that I can compile against this XSD, with 0 warnings.
  Note it uses &quot;element(tag,type)&quot;</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;
      xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
      xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot;
      exclude-result-prefixes=&quot;xs msxsl&quot;
      version=&quot;2.0&quot;&gt;
  
    &lt;xsl:output method=&quot;xml&quot; indent=&quot;yes&quot; encoding=&quot;UTF-8&quot; version=&quot;1.0&quot;/&gt;
  
    &lt;xsl:import-schema schema-location=&quot;MessingAbout.xsd&quot;/&gt;
    &lt;xsl:template match=&quot;/&quot;&gt;
      &lt;xsl:apply-templates select=&quot;SQUARE&quot;/&gt;
    &lt;/xsl:template&gt;
    &lt;xsl:template match=&quot;element(SQUARE,FILLEDSQUARETYPE)&quot;&gt;
      &lt;foo&gt;
        &lt;xsl:value-of select=&quot;@colour&quot;/&gt;
      &lt;/foo&gt;
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  <p>I can apply that transform to xmls like this.</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
  &lt;SQUARE x=&quot;1&quot; y=&quot;2&quot; width=&quot;234&quot; kind=&quot;FILLEDSQUARETYPE&quot; colour=&quot;red&quot;&gt;
    &lt;contains/&gt;
  &lt;/SQUARE&gt;
  </code></pre>
  <p>and get</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;foo&gt;red&lt;/foo&gt;
  </code></pre>
  <p>HURRAY!</p>
  <p>but...this is a simplification of my &quot;real world&quot; scenario.
  In my real world scenario the source system is optimised to only export XML that's required by the transform, (and the schema describes a utopian world where all data is exported, with mandatory data, even if thats not required)</p>
  <p>so, for example, the attribute &quot;width&quot;, &quot;x&quot;, &quot;y&quot; arent required by the transform, so would be excluded...like this..</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
  &lt;SQUARE kind=&quot;FILLEDSQUARETYPE&quot; colour=&quot;red&quot;&gt;
    &lt;contains/&gt;
  &lt;/SQUARE&gt;
  </code></pre>
  <p>If we now apply the transformation (with SchemaValidationMode.Strict) to this XML then saxon will complain.</p>
  <p>It will automatically validate the input.</p>
  <pre><code>Validation error on line 2 column 46
    FORG0001: Required attribute @Q{}y is missing on element &lt;SQUARE&gt;
    Validating /SQUARE[1]
    See http://www.w3.org/TR/xmlschema11-1/#cvc-complex-type clause 4
  Validation error on line 2 column 46
    FORG0001: Required attribute @Q{}x is missing on element &lt;SQUARE&gt;
    Validating /SQUARE[1]
    See http://www.w3.org/TR/xmlschema11-1/#cvc-complex-type clause 4
  Validation error on line 2 column 46
    FORG0001: Required attribute @Q{}width is missing on element &lt;SQUARE&gt;
    Validating /SQUARE[1]
    See http://www.w3.org/TR/xmlschema11-1/#cvc-complex-type clause 4
  Validation error on line 4 column 10
    XTTE1510: Three validation errors were reported. First error: Required attribute @Q{}y is
    missing on element &lt;SQUARE&gt;
  </code></pre>
  <p>Even though these errors are irrelevant to my XSLT, in my scenario this is a bit of an issue, ideally I'd like to turn off this behaviour, so that saxon doesnt try to validate things that are irrelevant to the execution of the XSLT.</p>
  <p>Any ideas?</p>
  <p>(I can obviously create a schema for the subset of data that IS exported, but this is actually quite onerous, and has nasty implications where effectively multiple types need to exist to describe effectively the same utopian data, when different subsets of children are exported.
  I can also turn everything to optional, but this massively diminishes the value of the type check).</p>