Hello,
If I understand the spec for this function[1] correctly, at most one element should be returned for a given ID value:
"If several elements have the same ID value, then E is the one that is first in document order."("Rules", item 3)
BaseX behaves differently from e.g. Saxon in this respect. The query:
let $doc := document{<foo xml:id='a1'><bar xml:id='a1'/></foo>}
return (
'Saxon-HE 11.6:',
xslt:transform($doc, <xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.0">
<xsl:template match="/">
<xsl:sequence select="id('a1')"/>
</xsl:template>
</xsl:stylesheet>),
'BaseX 10.7:',
$doc/id('a1')
)
returns:
Saxon-HE 11.6:
<foo xml:id="a1"><bar xml:id="a1"/></foo>
BaseX 10.7:
<foo xml:id="a1"><bar xml:id="a1"/></foo>
<bar xml:id="a1"/>
i.e. Saxon returns only the first in document order, whereas BaseX returns both of them.
Grateful for your thoughts,
Andrew