Project

Profile

Help

Bug #2435

closed

Equality fails due to type comparison

Added by Nick Evans over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Category:
Schema-Aware processing
Sprint/Milestone:
Start date:
2015-08-04
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.6
Fix Committed on Branch:
9.6
Fixed in Maintenance Release:
Platforms:

Description

Consider the following XSD:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           targetNamespace="http://www.xpathtest.com/test"
           xmlns:test="http://www.xpathtest.com/test"
           elementFormDefault="qualified">
  <xs:element name="comparables">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="test:comparable" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="comparable">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="string" type="xs:string"/>
        <xs:element name="int" type="xs:integer"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

and the following instance:

<comparables xmlns="http://www.xpathtest.com/test">
  <comparable>
    <string>hello</string>
    <int>1</int>
  </comparable>
  <comparable>
    <string>hello</string>
    <int>1</int>
  </comparable>
</comparables>

If I run the following XPath expression using Saxon 9.6.0-4:

//test:comparable[1]/test:int eq //test:comparable[2]/test:int

it fails with the message "Cannot compare xs:integer to xs:integer". If I replace this expression with the following:

//test:comparable[1]/test:int*1 eq //test:comparable[2]/test:int*1

it returns "true" as expected. It seems that something is amiss in the way Saxon is handling the types of the expressions being compared.

Please register to edit this issue

Also available in: Atom PDF