package xml

Import Path
	github.com/aws/smithy-go/encoding/xml (on go.dev)

Dependency Relation
	imports 9 packages, and imported by 2 packages

Involved Source Files array.go constants.go Package xml holds the XMl encoder utility. This utility is written in accordance to our design to delegate to shape serializer function in which a xml.Value will be passed around. Resources followed: https://smithy.io/2.0/spec/protocol-traits.html#xml-bindings Member Element Member element should be used to encode xml shapes into xml elements except for flattened xml shapes. Member element write their own element start tag. These elements should always be closed. Flattened Element Flattened element should be used to encode shapes marked with flattened trait into xml elements. Flattened element do not write a start tag, and thus should not be closed. Simple types encoding All simple type methods on value such as String(), Long() etc; auto close the associated member element. Array Array returns the collection encoder. It has two modes, wrapped and flattened encoding. Wrapped arrays have two methods Array() and ArrayWithCustomName() which facilitate array member wrapping. By default, a wrapped array members are wrapped with `member` named start element. <wrappedArray><member>apple</member><member>tree</member></wrappedArray> Flattened arrays rely on Value being marked as flattened. If a shape is marked as flattened, Array() will use the shape element name as wrapper for array elements. <flattenedAarray>apple</flattenedArray><flattenedArray>tree</flattenedArray> Map Map is the map encoder. It has two modes, wrapped and flattened encoding. Wrapped map has Array() method, which facilitate map member wrapping. By default, a wrapped map members are wrapped with `entry` named start element. <wrappedMap><entry><Key>apple</Key><Value>tree</Value></entry><entry><Key>snow</Key><Value>ice</Value></entry></wrappedMap> Flattened map rely on Value being marked as flattened. If a shape is marked as flattened, Map() will use the shape element name as wrapper for map entry elements. <flattenedMap><Key>apple</Key><Value>tree</Value></flattenedMap><flattenedMap><Key>snow</Key><Value>ice</Value></flattenedMap> element.go encoder.go error_utils.go escape.go map.go value.go xml_decoder.go
Package-Level Type Names (total 13, in which 10 are exported)
/* sort exporteds by: | */
Array represents the encoding of a XML array type Member adds a new member to the XML array. It returns a Value encoder. func Value.Array() *Array func Value.ArrayWithCustomName(element StartElement) *Array
An Attr represents an attribute in an XML element (Name=Value). Name Name Value string func NewAttribute(local, value string) Attr func NewNamespaceAttribute(local, value string) Attr
Encoder is an XML encoder that supports construction of XML values using methods. The encoder takes in a writer and maintains a scratch buffer. Bytes returns the []byte slice of the XML encoder RootElement builds a root element encoding It writes it's start element tag. The value should be closed. String returns the string output of the XML encoder Encoder : expvar.Var Encoder : fmt.Stringer func NewEncoder(w writer) *Encoder
An EndElement represents an XML end element. Name Name func StartElement.End() EndElement
ErrorComponents represents the error response fields that will be deserialized from an xml error response body Code string Message string func GetErrorResponseComponents(r io.Reader, noErrorWrapping bool) (ErrorComponents, error)
Map represents the encoding of a XML map type Entry returns a Value encoder with map's element. It writes the member wrapper start tag for each entry. func Value.Map() *Map
A Name represents an XML name (Local) annotated with a name space identifier (Space). In tokens returned by Decoder.Token, the Space identifier is given as a canonical URL, not the short prefix used in the document being parsed. Local string Space string
NodeDecoder is a XML decoder wrapper that is responsible to decoding a single XML Node element and it's nested member elements. This wrapper decoder takes in the start element of the top level node being decoded. Decoder *xml.Decoder StartEl xml.StartElement GetElement looks for the given tag name at the current level, and returns the element if found, and skipping over non-matching elements. Returns an error if the node is not found, or if an error occurs while walking the document. Token on a Node Decoder returns a xml StartElement. It returns a boolean that indicates the a token is the node decoder's end node token; and an error which indicates any error that occurred while retrieving the start element Value provides an abstraction to retrieve char data value within an xml element. The method will return an error if it encounters a nested xml element instead of char data. This method should only be used to retrieve simple type or blob shape values as []byte. func WrapNodeDecoder(decoder *xml.Decoder, startEl xml.StartElement) NodeDecoder
A StartElement represents an XML start element. Attr []Attr Name Name Copy creates a new copy of StartElement. End returns the corresponding XML end element. func StartElement.Copy() StartElement func Encoder.RootElement(element StartElement) Value func Value.ArrayWithCustomName(element StartElement) *Array func Value.FlattenedElement(element StartElement) Value func Value.MemberElement(element StartElement) Value
Value represents an XML Value type XML Value types: Object, Array, Map, String, Number, Boolean. Array returns an array encoder. By default, the members of array are wrapped with `<member>` element tag. If value is marked as flattened, the start element is used to wrap the members instead of the `<member>` element. ArrayWithCustomName returns an array encoder. It takes named start element as an argument, the named start element will used to wrap xml array entries. for eg, `<someList><customName>entry1</customName></someList>` Here `customName` named start element will be wrapped on each array member. Base64EncodeBytes writes v as a base64 value in XML string. It will auto close the parent xml element tag. BigDecimal encodes v big.Float as XML value. It will auto close the parent xml element tag. BigInteger encodes v big.Int as XML value. It will auto close the parent xml element tag. Boolean encodes v as a XML boolean. It will auto close the parent xml element tag. Byte encodes v as a XML number. It will auto close the parent xml element tag. Close closes the value. Double encodes v as a XML number. It will auto close the parent xml element tag. FlattenedElement returns flattened element encoding. It returns a Value. This method should be used for flattened shapes. Unlike MemberElement, flattened element will NOT write element tags directly for the associated start element. The value returned by the FlattenedElement does not need to be closed. Float encodes v as a XML number. It will auto close the parent xml element tag. Integer encodes v as a XML number. It will auto close the parent xml element tag. IsFlattened returns true if value is for flattened shape. Long encodes v as a XML number. It will auto close the parent xml element tag. Map returns a map encoder. By default, the map entries are wrapped with `<entry>` element tag. If value is marked as flattened, the start element is used to wrap the entry instead of the `<member>` element. MemberElement does member element encoding. It returns a Value. Member Element method should be used for all shapes except flattened shapes. A call to MemberElement will write nested element tags directly using the provided start element. The value returned by MemberElement should be closed. Short encodes v as a XML number. It will auto close the parent xml element tag. String encodes v as a XML string. It will auto close the parent xml element tag. Write writes v directly to the xml document if escapeXMLText is set to true, write will escape text. It will auto close the parent xml element tag. func (*Array).Member() Value func Encoder.RootElement(element StartElement) Value func (*Map).Entry() Value func Value.FlattenedElement(element StartElement) Value func Value.MemberElement(element StartElement) Value
Package-Level Functions (total 19, in which 6 are exported)
FetchRootElement takes in a decoder and returns the first start element within the xml body. This function is useful in fetching the start element of an XML response and ignore the comments and preamble
GetErrorResponseComponents returns the error fields from an xml error response body
NewAttribute returns a pointer to an attribute. It takes in a local name aka attribute name, and value representing the attribute value.
NewEncoder returns an XML encoder
NewNamespaceAttribute returns a pointer to an attribute. It takes in a local name aka attribute name, and value representing the attribute value. NewNamespaceAttribute appends `xmlns:` in front of namespace prefix. For creating a name space attribute representing `xmlns:prefix="http://example.com`, the breakdown would be: local = "prefix" value = "http://example.com"
WrapNodeDecoder returns an initialized XMLNodeDecoder
Package-Level Variables (total 13, none are exported)
Package-Level Constants (total 6, none are exported)