distinct-values in XQuery

declare namespace xs=‘XML Schema
let $listKeys := distinct-values(
for $b in input()/oDocument [
/oDocument/@type=‘Element’
and /oDocument/@parent = ‘C13ECC62C52B8000’]
/attributes/attribute
where $b/@key=‘C13ED8481ECA0000’ and $b/text() != 123
return $b/@oDocKey
)

return $listKeys

This example works
/*-------------------------------------------------------------------

And here this returns a error

declare namespace xs=‘XML Schema
let $listKeys := distinct-values(
for $b in input()/oDocument [
/oDocument/@type=‘Element’
and /oDocument/@parent = ‘C13ECC62C52B8000’]
/attributes/attribute
where $b/@key=‘C13ED8481ECA0000’ and xs:int($b/text()) != 123
return $b/@oDocKey
)

return $listKeys

Conversion error for comparison The source type is: anySimpleType, the target type is: double.

/*------------------------------------------------------------------
In what a problem?

An initial comment: you don

I thought that too, but it works like this!

declare namespace xs='http://www.w3.org/2001/XMLSchema' 
let $listKeys := ( 
for $b in input()/oDocument [ 
/oDocument/@type='Element' 
and /oDocument/@parent = 'C13ECC62C52B8000'] 
/attributes/attribute 
where $b/@key='C13ED8481ECA0000' and xs:int($b/text()) != 123 
return $b/@oDocKey 
)
return $listKeys

And on sharing of function distinct-values(); and xs:int() gives out a mistake

Then I don

Full text XQuery:

 
declare namespace xs='http://www.w3.org/2001/XMLSchema' 
 let $oDocs := ( 
 for $b in input()/oDocument[
          /oDocument/@type='Елемент' and 
          /oDocument/@parent='C13ECC62C52B8000'
          ]/attributes/attribute  
where ($b/@key='C13ED8481ECA0000' and $b/text()!= '123')
return $b/@oDocKey) [position() >= 0 and position() <= 10] 
         
 return ($oDocs)

OR

 
declare namespace xs='http://www.w3.org/2001/XMLSchema' 
 let $oDocs := ( 
 for $b in input()/oDocument[
          /oDocument/@type='&#1045;&#1083;&#1077;&#1084;&#1077;&#1085;&#1090;' and 
          /oDocument/@parent='C13ECC62C52B8000'
          ]/attributes/attribute  
where ($b/@key='C13ED8481ECA0000' and xs:int($b/text())!= 123)
return $b/@oDocKey) [position() >= 0 and position() <= 10] 
         
 return ($oDocs)

Result:

  • <xq:result xmlns:xq="…">
    <xq:value xmlns:xq="…">C14415073F3F0000</xq:value>
    xq:valueC14415088B088000</xq:value>
    xq:valueC14415090CEA8000</xq:value>
    xq:valueC14415090CEA8000</xq:value>
    xq:valueC1441509BC358000</xq:value>
    xq:valueC144150A0C498000</xq:value>
    xq:valueC144150A0C498000</xq:value>
    xq:valueC144150AA4E00000</xq:value>
    xq:valueC144150ACEDE0000</xq:value>
    xq:valueC144150B083D8000</xq:value>
    </xq:result>
  • <ino:cursor ino:handle=“1”>
    <ino:current ino:position=“1” ino:quantity=“10” />
    <ino:next ino:position=“11” />
    </ino:cursor>

I think at this point I would contact Software AG support. It looks like a bug.