Add smithy-xml package#655
Add smithy-xml package#655arandito wants to merge 1 commit intosmithy-lang:feat/add-query-protocolfrom
Conversation
Reviewer NoteThe current XML serializer builds a DOM tree in memory and only writes it to the output sink when I explored implementing a streaming XML writer to avoid this but ran into an issue with XML attributes. In XML, members marked with One possible solution is a two-pass approach: first serialize attribute members normally while sending others to a null serializer, then serialize non-attribute members while sending attribute members to a null serializer. This allows the opening tag and its attributes to be written before child elements. However, this introduces additional complexity compared to the current approach without a substantial benefit. This creates some asymmetry with the current XML deserializer, which reads incrementally from the byte source rather than a DOM. I am open to switching the serializer to a streaming implementation if parity or avoiding the intermediate DOM is preferred. |
Description
This PR adds an initial implementation of the new
smithy-xmlruntime package, which provides generic XML serialization and deserialization support for Smithy clients and servers.This work primarily supports the XML deserialization path needed by the
awsQueryprotocol. The serializer is also included as an initial implementation but will not be used immediately. If necessary, we could omit the serializer for now and introduce it later alongside therestXmlprotocol, where XML request serialization is required and the behavior can be validated more thoroughly.The implementation follows the XML binding rules defined in the Smithy awsQuery and restXml protocol specifications, including support for the following traits:
@xmlName,@xmlAttribute,@xmlFlattened, and@xmlNamespace(defined insmithy-core).Important
This implementation follows the Smithy Python Protocol Serialization and Deserialization design. I strongly recommend reviewing this document first to better understand the implementation.
Testing
Added round trip serde test cases that follow the same testing strategy as
smithy-json.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.