title: SaxonB 9.0 vs. SaxonB 9.1.0.8 and xs:boolean vs. xs:string type error
body: <p>I have upgraded from SaxonB (XSLT 2.0 processor) version 9.0 to 9.1.0.8 and my program (<a href="https://trac.frantovo.cz/xml-web-generator/" rel="nofollow">XML Web Generator</a>) stopped working.</p>
  
  <p>The XSLT transformation is executed using Ant. And Saxon now complains:</p>
  
  <pre><code> [xslt] .../stránka.xsl:37: Fatal Error! Required type is xs:boolean; supplied value has type xs:string
   [xslt] Failed to process null
  </code></pre>
  
  <p>But on line 37 of that XSLT file there is:</p>
  
  <pre><code>&lt;xsl:include href="stránka-společné.xsl"/&gt;
  </code></pre>
  
  <p>and it is probably not the problem. It might be on line 47 where I use a property (set from Ant) in &lt;xsl:if test="$someProperty"/&gt;</p>
  
  <p>The property is declared in included XSL file:</p>
  
  <pre><code>&lt;xsl:param name="someProperty" select="false()" as="xs:boolean"/&gt;
  </code></pre>
  
  <p>I use unicode characters in the property name, but it should work, shouldn't it? (at least it worked in 9.0). I tried to use ASCII and it didn't help.</p>
  
  <p>It is also not about Ant or Java version because whether it works or not depends only on the path to JAR file (9.0 vs. 9.1.0.8).</p>
  
  <p>I would like to make the application compatible with 9.1.0.8. (Or is it a bug in SaxonB?)</p>
  
  <p>Versions I have used (SHA-256):</p>
  
  <pre><code>3cb7336b154eabfb0d78a1b9b5f7c70e15a9c790193676803fa4391b60de7ebb  saxonb-9.0.jar (working)
  dc09c0e3d03609ff3c11b1e19446ca82a5f7f1bc364173b7910f2267312bd7d5  saxonb-9.1.0.8.jar (error described above)
  </code></pre>
  
  <p>Files can be found e.g. at <a href="http://packages.ubuntu.com/" rel="nofollow">package.ubuntu.com</a> inside .deb files – package <code>libsaxonb-java</code> in lucid (9.0) or raring (9.1.0.8).</p>
  
  <p><strong>Update #1</strong></p>
  
  <p>If I remove usages of this problematic property (variable in XSLT) I got different error:</p>
  
  <pre><code> [xslt] Failed to process null
  
  BUILD FAILED
  …/build.xml:39: ; SystemID: file:…/šablona/makra/diagramy.xsl; Line#: 63; Column#: -1
  net.sf.saxon.instruct.TerminationException: Processing terminated by xsl:message at line 89 in diagramy.xsl
      at net.sf.saxon.instruct.Message.processLeavingTail(Unknown Source)
      at net.sf.saxon.instruct.Choose.processLeavingTail(Unknown Source)
      at net.sf.saxon.expr.LetExpression.processLeavingTail(Unknown Source)
      …
  </code></pre>
  
  <p>Which is also specific for version 9.1.0.8 (with 9.0 I got no error). On line 63 in <code>diagramy.xsl</code> there is:</p>
  
  <pre><code>&lt;xsl:variable name="souborDiagramu" select="j:vytvořDiagram(
      $zadání, 
      @orientace = 'vodorovně', 
      $kompletní,
      tokenize(base-uri(), '/')[last()],
      @src
      )"/&gt;
  </code></pre>
  
  <p>Where <code>@orientace</code> and <code>@src</code> are missing in the source document (in 9.0 such attributes were passed to Java method <code>vytvořDiagram(…)</code> as <code>null</code> arguments).</p>
  
  <p><strong>Update #2</strong></p>
  
  <p>I wrote a function in Java to get type of a property:</p>
  
  <pre><code>public static String zjistiTyp(Object o) {
      if (o == null) {
          return "null";
      } else {
          return o.getClass().getName();
      }
  }
  </code></pre>
  
  <p>With version 9.0 this</p>
  
  <pre><code>&lt;xsl:message&gt;Typ proměnné $podporaZaostalýchProhlížečů = &lt;xsl:value-of select="j:zjistiTyp($podporaZaostalýchProhlížečů)"/&gt;&lt;/xsl:message&gt;
  </code></pre>
  
  <p>succesfully prints:</p>
  
  <pre><code> [xslt] Typ proměnné $podporaZaostalýchProhlížečů = java.lang.Boolean
  </code></pre>
  
  <p>But with 9.1.0.8 I got error <code>Required type is xs:boolean; supplied value has type xs:string</code> even if I removed any other obstacles (usages of this property) and the transformation continues if I remove the last usage of it: <code>&lt;xsl:message&gt;Typ proměnné…</code> (but then I can't find out the type of the property).</p>
  
  <p>So it looks like that a string <code>false</code> (or <code>true</code>) can be passed from Ant to XSLT and even the propery can be declared in XSLT using this construction:</p>
  
  <pre><code>&lt;xsl:param name="podporaZaostalýchProhlížečů" select="false()" as="xs:boolean"/&gt;
  </code></pre>
  
  <p>but it can not be used – the usage of such property causes error (but only in 9.1.0.8 – in 9.0 it is working).</p>
  
  <p><strong>Update #3</strong></p>
  
  <p>I found a workaround for one part of the problem.</p>
  
  <pre><code>&lt;xsl:param name="someParameterUncasted"/&gt;
  &lt;xsl:variable name="someParameter" select="$someParameterUncasted cast as xs:boolean"/&gt;
  </code></pre>
  
  <p>But this is ugly because I need two names for one parameter – different in Ant and different in XSLT. Is there any way how to pass Boolean-typed parameter from Ant to XSLT? Why this stopped working in Saxon 9.1.0.8 although it worked in 9.0?</p>
  
  <p>And there is also second part of the 9.0/9.1.0.8 problem: when passing value of some missing attribute to a Java method, in 9.0 it worked and Java simply got null. In 9.1.0.8 it causes an error.</p>