Hi Hans-Juergen,

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.

kind regards

O'Neil

On 05/10/11 13:06, Hans-Juergen Rennau wrote:
Hello Michael,

it seems to me there is a strange XQuery bug concerning sequence type matching.

Summry: typeswitch cases using "element(elemName)", as well as "instance of element(elemName)" do not match when they should; but the equivalent comparison of node names matches, as it should.
But this, of course, only in a very special context, which is given by how the candidate is provided:
   $def/(* except xs:annotation)

For full example code see below.

Version: saxon9-3-0-5j

Kind regards,
-- Hans-Juergen

Output:
==========
<result>
   <xs:restriction xmlns:xs="http://www.w3.org/2001/XMLSchema" base="xs:string"/>
   <NOMATCH_TYPESWITCH/>
   <NOMATCH_INSTANCEOF/>
   <MATCH_NODENAME/>
</result>
==========

Code:
==========
declare namespace xs="http://www.w3.org/2001/XMLSchema";
let $def :=
   <xs:simpleType name="yogi">
      <xs:restriction base="xs:string"/>
   </xs:simpleType>
let $ref := $def/xs:restriction
return

   <result>{
      for $c in $def/(* except xs:annotation) return (
         $c,
         typeswitch($c)
         case element(xs:restriction) return <MATCH_TYPESWITCH/>
         default return <NOMATCH_TYPESWITCH/>
         ,
         if ($c instance of element(xs:restriction))
         then <MATCH_INSTANCEOF/>
         else <NOMATCH_INSTANCEOF/>
         ,
         if (node-name($c) eq node-name($ref))
         then <MATCH_NODENAME/>
         else <NOMATCH_NODENAME/>
      )     
   }</result>
==========

------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help


--
O'Neil Delpratt
Software Developer, Saxonica Limited
Email: oneil@saxonica.com
Tel: +44 118 946 5894
Web: http://www.saxonica.com