Hello O'Neil,
 
probably this is again the same bug already reported and fixed. You wrote:
"Thanks very much for reporting the bug, which has now been noted (sourceforge Bug report ID: 3419499) and the bug is now fixed, which will appear in the next patch release."
 
But as I am not sure I report it again, as now the context is slightly different (stylesheet vs. query).
 
Summry: if (element(elemName)) does not match when it should; but the equivalent comparison of node names matches.
 
The earlier report stated:
"But this, of course, only in a very special context, which is given by how the candidate is provided:
   $def/(* except xs:annotation)
"
Whereas now I observe the problem in a stylesheet - see below for a snippet. Please just ignore this posting if you are sure the bug is fixed (in 9.3.0.6 which is not yet available for HE).
 
Kind regards from
-- Hans-Juergen
 
Snippet: The when-test fails when I remove the third alternative (... or local-name($baseType) ..."):
==========================
   :::
   <xsl:variable name="baseType" as="element()?">
      <xsl:variable name="baseTypeQName" select="(xs:extension, xs:restriction)/resolve-QName(@base, .)"/>
      <xsl:sequence select="$xsds/(xs:simpleType, xs:complexType)[QName(ancestor::xs:schema/@targetNamespace, @name) eq $baseTypeQName]"/>
   </xsl:variable>
   <xsl:choose>
      <xsl:when test="not($baseType)
                      or $baseType is element(xs:simpleType)
                      or local-name($baseType) eq 'simpleType' and namespace-uri($baseType) eq 'http://www.w3.org/2001/XMLSchema'">
         ...        
==========================