From 77eff51d6feb5c04378e6dfed390da9df2b651ac Mon Sep 17 00:00:00 2001 From: Michael Kay Date: Thu, 9 Jan 2025 23:08:41 +0000 Subject: [PATCH] Add xsl:map/@select --- .../xslt-40/src/element-catalog.xml | 3 + specifications/xslt-40/src/xslt.xml | 55 +++++++++++++++---- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/specifications/xslt-40/src/element-catalog.xml b/specifications/xslt-40/src/element-catalog.xml index d3cb696cd..fdaa0f0ed 100644 --- a/specifications/xslt-40/src/element-catalog.xml +++ b/specifications/xslt-40/src/element-catalog.xml @@ -1659,6 +1659,9 @@ + + + diff --git a/specifications/xslt-40/src/xslt.xml b/specifications/xslt-40/src/xslt.xml index ad63a5942..22de3c027 100644 --- a/specifications/xslt-40/src/xslt.xml +++ b/specifications/xslt-40/src/xslt.xml @@ -22005,7 +22005,8 @@ and version="1.0" otherwise.

For the elements xsl:sequence, xsl:on-empty, xsl:on-non-empty, xsl:when, xsl:otherwise, xsl:matching-substring, - xsl:non-matching-substring, xsl:array, + xsl:non-matching-substring, xsl:map, + xsl:map-entry, xsl:array, xsl:array-member, and xsl:result-document, it is a static error if the select attribute is present @@ -35508,6 +35509,18 @@ the same group, and the--> Map Instructions + + + The xsl:map instruction allows a select attribute + as an alternative to the contained sequence constructor. + + + The xsl:map-entry instruction, in common with other instructions, + now raises error XTSE3185 (rather than XTSE3280) if both a select + attribute and a sequence constructor are present. + + +

Two instructions are added to XSLT to facilitate the construction of maps.

@@ -35515,9 +35528,15 @@ the same group, and the-->

The instruction xsl:map constructs and returns a new map.

+

The select attribute and the contained sequence constructor are mutually + exclusive: if a select attribute is present, then the content + must be empty except optionally for + xsl:fallback instructions.

+

The result of evaluating the select expression or the contained + sequence constructor is referred to as the input sequence.

-

The contained sequence constructor must evaluate to a sequence of +

The input sequence must be a sequence of maps: call this $maps.

In the absense of duplicate keys, the result of the instruction @@ -35534,7 +35553,7 @@ the same group, and the--> -

There is no requirement that the supplied input maps should have the same or +

There is no requirement that the maps in the input sequence should have the same or compatible types. The type of a map (for example map(xs:integer, xs:string)) is descriptive of the entries it currently contains, but is not a constraint on how the map may be combined with other maps.

@@ -35548,15 +35567,16 @@ the same group, and the-->

-

A type error occurs if the result of evaluating the sequence constructor - within an xsl:map instruction is +

A type error occurs if the result of the input sequence + of an xsl:map instruction is not an instance of the required type map(*)*.

-

In practice, the effect of this rule is that the sequence +

In practice, the effect of this rule is that the result of the + select expression or sequence constructor contained in the xsl:map instruction is severely constrained: it doesn’t make sense, for example, for it to contain instructions such as xsl:element that create new nodes. As with @@ -35564,6 +35584,13 @@ the same group, and the--> able to determine that the sequence constructor would always fail when evaluated.

+ + +

It is legitimate to construct a map using an instruction such as + <xsl:map select="{'a':1, 'b':2}"/>. In this situation + xsl:map has exactly the same effect as xsl:sequence, + but users may feel that it improves readability.

+
@@ -35575,16 +35602,16 @@ the same group, and the-->

The select attribute and the contained sequence constructor are mutually exclusive: if a select attribute is present, then the content must be empty except optionally for - xsl:fallback instructions.

+ xsl:fallback instructions.

-

+ @@ -35658,6 +35685,10 @@ the same group, and the--> </xsl:for-each> </xsl:map> +

This could also be written:

+ +]]> @@ -35671,7 +35702,7 @@ the same group, and the--> -

This section describes what happens when two or more maps returned by the sequence constructor +

This section describes what happens when two or more maps in the input sequence of within an xsl:map instruction contain duplicate keys: that is, when one of these maps contains an entry with key K, and another contains an entry with key L, and fn:atomic-equal(K, L) returns true.

@@ -35679,8 +35710,8 @@ the same group, and the-->

In the absence of the on-duplicates attribute, a dynamic error occurs if the set of - keys in the maps resulting from evaluating the sequence constructor - within an xsl:map instruction + keys in the maps making up the input sequence + of an xsl:map instruction contains duplicates.