xsl-list
[Top] [All Lists]

Re: [xsl] Using QNames as keys in maps

2018-02-15 03:51:13
Am 15.02.2018 um 10:28 schrieb Erik Siegel erik(_at_)xatapult(_dot_)nl:

I’m trying to set up a map(xs:QName, item()), in an XSLT 3.0 stylesheet, but it’s very inconvenient. This works:

(Running in  oXygen 19.1 which reports Saxon 9.7.0.19, tried both PE and EE)

<xsl:template match="/">

    <xsl:variable name="qmap" as="map(xs:QName, item())" select="map{ QName((), 'xx'): 'aaa' }"/>

    <RESULT size="{map:size($qmap)}">

      <xsl:value-of select="map:get($qmap, QName((), 'xx'))"/>

    </RESULT>

</xsl:template>

But I would have expected this to work also (but it doesn’t):

<xsl:template match="/">

  <xsl:variable name="qmap" as="map(xs:QName, item())" select="map{ Q{}xx: 'aaa' }"/>

  <RESULT size="{map:size($qmap)}">

    <xsl:value-of select="map:get($qmap, Q{}xx)"/>

  </RESULT>

</xsl:template>


If you use Q{}xx then you don't construct a QName, instead you select any xx children of the context node.

The only other option you have to construct a QName is xs:QName('xx').
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>