From 864cc60d19fa790bf8daf52db30357ff557bd179 Mon Sep 17 00:00:00 2001
From: James Clark
A field-access-expr accesses a field of an object or a member of a mapping. The
-semantics depends on the static type T of expression.
+semantics depends on the static type T of expression. A field-access-expr where
+T is a subtype of xml is interpreted as an xml-required-attribute-access-expr.
If T is a subtype of the object basic type, then T must have a field field-name
@@ -3674,6 +3675,10 @@ Field access expression
Optional field access expression
returning ()
if the member does not exist.
+An optional-field-access-expr where the static type of expression
is
+a subtype of xml is interpreted as an xml-optional-attribute-access-expr.
+
Let T be the static type of expression, let T' be the intersection of T and basic type list, let K be the singleton type containing just the string field-name and let M be the member type of K in T'. The compile-time @@ -3724,22 +3729,22 @@
.
xml-attribute-name
xml-optional-attribute-access-expr := expression ?.
xml-attribute-name
-xml-attribute-name := xml-qualified-name | qualified-identifier
+xml-attribute-name := xml-qualified-name | qualified-identifier | identifier
-An XML attribute access expression provides convenient access to a -namespace-qualified attribute. -
--It is a compile-time requirement that the static type of the expression is a -subtype of xml. +An XML attribute access expression provides convenient access to an attribute of +an XML element. It is a compile-time requirement that the static type of the +expression is a subtype of xml.
-Normally, an xml-attribute-name is specified as an xml-qualified-name, in which +A string representing the name of the attribute is computed at compile-time from +the xml-attribute-name. When the xml-attribute-name is an identifier without a +prefix, the attribute name string is the identifier. When the xml-attribute-name +has a prefix, normally the xml-attribute-name is an xml-qualified-name, in which the prefix is an xml-namespace-prefix declared using an xmlns-decl. In this -case, the xml-qualified-name is expanded at compile-time into a string of the -form +case, the xml-qualified-name is expanded at compile-time into an attribute name +string of the form
{namespace-uri}local-name @@ -3752,19 +3757,18 @@XML attribute access expression
It is also allowed for the xml-attribute-name to be specified as a qualified-identifier, in which the prefix is a module-prefix declared using an import-decl. In this case the qualified-identifier must refer to a -module-const-decl of type string, and the expansion of the xml-qualified-name is -the value of the referenced constant. This allows e.g.xml:lang
to -work. +module-const-decl of type string, and the attribute name string is the value of +the referenced constant. This allows e.g.xml:lang
to work.An xml-optional-attribute-access-expr is evaluated as follows. The expression is evaluated resulting in an xml value v. If v is an empty xml value, the result is
()
. Otherwise, if v is not a singleton element, the result is an error. Otherwise, let m be that -element's attribute map. Let k be the string that results from -expanding the xml-qualified-name, as described in the previous paragraph. If -m has a member s with keyk
, the the result -is s. Otherwise, the result is()
. +element's attribute map and let k be the attribute name string +computed at compile-time from the xml-attribute-name. If m has a +member s with key k, the the result is s. +Otherwise, the result is()
.An xml-required-attribute-access-expr is evaluated the same as an