Skip to content

Commit

Permalink
Allow xmlName on union shapes
Browse files Browse the repository at this point in the history
Because union shapes can be targeted by the httpPayload trait, we need
to allow xmlName on unions to alter the outermost wrapper that is used
to serialize the union when using a REST + XML protocol.
  • Loading branch information
mtdowling committed Jan 6, 2020
1 parent 4802323 commit c7148b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
23 changes: 12 additions & 11 deletions docs/source/spec/xml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ if necessary.
Structure and union serialization
=================================

All XML serialization starts with a structure. The shape name of a structure
is used as the outermost XML element name. Members of a structure or union
shape are serialized as nested XML elements where the name of the element is
the same as the name of the member.
All XML serialization starts with a structure or union. The shape name of a
structure/union is used as the outermost XML element name. Members of a
structure/union are serialized as nested XML elements where the name of the
element is the same as the name of the member.

For example, given the following:

Expand Down Expand Up @@ -61,11 +61,11 @@ The :ref:`xmlattribute-trait` is used to serialize a structure
member as an XML attribute.


``xmlName`` on structures
-------------------------
``xmlName`` on structures and unions
------------------------------------

An ``xmlName`` trait applied to a structure changes the element name of the
serialized structure; however, it does not influence the serialization of
An ``xmlName`` trait applied to a structure or union changes the element name
of the serialized shape; however, it does not influence the serialization of
members that target it. Given the following:

.. tabs::
Expand Down Expand Up @@ -849,11 +849,12 @@ The XML serialization is:
-----------------

Summary
Changes the serialized element or attribute name of a structure or member.
Changes the serialized element or attribute name of a structure, union,
or member.
Trait selector
``:test(structure, member)``
``:test(structure, union, member)``

*A structure or member*
*A structure, union, or member*
Value type
``string`` value that MUST adhere to the :token:`xml_name` ABNF production:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ structure xmlAttribute {}
@tags(["diff.error.const"])
structure xmlFlattened {}

/// Changes the serialized element or attribute name of a structure or member.
@trait(selector: ":test(structure, member)")
/// Changes the serialized element or attribute name of a structure, union, or member.
@trait(selector: ":test(structure, union, member)")
@tags(["diff.error.const"])
@pattern("^[a-zA-Z_][a-zA-Z_0-9-]*(:[a-zA-Z_][a-zA-Z_0-9-]*)?$")
string xmlName
Expand Down

0 comments on commit c7148b9

Please sign in to comment.