src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

doc.go (2065B)


      1 /*
      2 Package xml holds the XMl encoder utility. This utility is written in accordance to our design to delegate to
      3 shape serializer function in which a xml.Value will be passed around.
      4 
      5 Resources followed: https://smithy.io/2.0/spec/protocol-traits.html#xml-bindings
      6 
      7 Member Element
      8 
      9 Member element should be used to encode xml shapes into xml elements except for flattened xml shapes. Member element
     10 write their own element start tag. These elements should always be closed.
     11 
     12 Flattened Element
     13 
     14 Flattened element should be used to encode shapes marked with flattened trait into xml elements. Flattened element
     15 do not write a start tag, and thus should not be closed.
     16 
     17 Simple types encoding
     18 
     19 All simple type methods on value such as String(), Long() etc; auto close the associated member element.
     20 
     21 Array
     22 
     23 Array returns the collection encoder. It has two modes, wrapped and flattened encoding.
     24 
     25 Wrapped arrays have two methods Array() and ArrayWithCustomName() which facilitate array member wrapping.
     26 By default, a wrapped array members are wrapped with `member` named start element.
     27 
     28 	<wrappedArray><member>apple</member><member>tree</member></wrappedArray>
     29 
     30 Flattened arrays rely on Value being marked as flattened.
     31 If a shape is marked as flattened, Array() will use the shape element name as wrapper for array elements.
     32 
     33 	<flattenedAarray>apple</flattenedArray><flattenedArray>tree</flattenedArray>
     34 
     35 Map
     36 
     37 Map is the map encoder. It has two modes, wrapped and flattened encoding.
     38 
     39 Wrapped map has Array() method, which facilitate map member wrapping.
     40 By default, a wrapped map members are wrapped with `entry` named start element.
     41 
     42 	<wrappedMap><entry><Key>apple</Key><Value>tree</Value></entry><entry><Key>snow</Key><Value>ice</Value></entry></wrappedMap>
     43 
     44 Flattened map rely on Value being marked as flattened.
     45 If a shape is marked as flattened, Map() will use the shape element name as wrapper for map entry elements.
     46 
     47 	<flattenedMap><Key>apple</Key><Value>tree</Value></flattenedMap><flattenedMap><Key>snow</Key><Value>ice</Value></flattenedMap>
     48 */
     49 package xml