Debian Codegraph @

parsing/xml/writer.go

raw symbols SCIP
1 package xmlscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.25 bytes/"
5 "encoding/xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/"
6 "fmtscip-go gomod github.com/golang/go/src go1.25 fmt/"
7 "stringsscip-go gomod github.com/golang/go/src go1.25 strings/"
8 "unicode/utf8scip-go gomod github.com/golang/go/src go1.25 `unicode/utf8`/"
9
10 "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/"
11 "github.com/tomwright/dasel/v3/parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/"
12 )
13
14 // isValidXMLNameStartChar reports whether r is a valid first character of an
15 // XML Name, per the XML 1.0 (Fifth Edition) specification §2.3.
16 func isValidXMLNameStartCharscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/isValidXMLNameStartChar().(r rune) bool {
17 return r == ':' || r == '_' ||
18 (r >= 'A' && r <= 'Z') ||
19 (r >= 'a' && r <= 'z') ||
20 (r >= 0xC0 && r <= 0xD6) ||
21 (r >= 0xD8 && r <= 0xF6) ||
22 (r >= 0xF8 && r <= 0x2FF) ||
23 (r >= 0x370 && r <= 0x37D) ||
24 (r >= 0x37F && r <= 0x1FFF) ||
25 (r >= 0x200C && r <= 0x200D) ||
26 (r >= 0x2070 && r <= 0x218F) ||
27 (r >= 0x2C00 && r <= 0x2FEF) ||
28 (r >= 0x3001 && r <= 0xD7FF) ||
29 (r >= 0xF900 && r <= 0xFDCF) ||
30 (r >= 0xFDF0 && r <= 0xFFFD) ||
31 (r >= 0x10000 && r <= 0xEFFFF)
32 }
33
34 // isValidXMLNameChar reports whether r is a valid subsequent character of an
35 // XML Name, per the XML 1.0 (Fifth Edition) specification §2.3.
36 func isValidXMLNameCharscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/isValidXMLNameChar().(r rune) bool {
37 return isValidXMLNameStartCharscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/isValidXMLNameStartChar().(r) ||
38 r == '-' || r == '.' ||
39 (r >= '0' && r <= '9') ||
40 r == 0xB7 ||
41 (r >= 0x0300 && r <= 0x036F) ||
42 (r >= 0x203F && r <= 0x2040)
43 }
44
45 // isValidXMLName reports whether s is a valid XML element or attribute name.
46 func isValidXMLNamescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/isValidXMLName().(s string) bool {
47 if s == "" {
48 return false
49 }
50 first, size := utf8scip-go gomod github.com/golang/go/src go1.25 `unicode/utf8`/.DecodeRuneInStringscip-go gomod github.com/golang/go/src go1.25 `unicode/utf8`/DecodeRuneInString().(s)
51 if (first == utf8scip-go gomod github.com/golang/go/src go1.25 `unicode/utf8`/.RuneErrorscip-go gomod github.com/golang/go/src go1.25 `unicode/utf8`/RuneError. && size == 1) || !isValidXMLNameStartCharscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/isValidXMLNameStartChar().(first) {
52 return false
53 }
54 for i := size; i < len(s); {
55 r, w := utf8scip-go gomod github.com/golang/go/src go1.25 `unicode/utf8`/.DecodeRuneInStringscip-go gomod github.com/golang/go/src go1.25 `unicode/utf8`/DecodeRuneInString().(s[i:])
56 if (r == utf8scip-go gomod github.com/golang/go/src go1.25 `unicode/utf8`/.RuneErrorscip-go gomod github.com/golang/go/src go1.25 `unicode/utf8`/RuneError. && w == 1) || !isValidXMLNameCharscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/isValidXMLNameChar().(r) {
57 return false
58 }
59 i += w
60 }
61 return true
62 }
63
64 func newXMLWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/newXMLWriter().(options parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.WriterOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#) (parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.Writerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#, error) {
65 return &xmlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#{
66 optionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#options.: options,
67 }, nil
68 }
69
70 type xmlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter# struct {
71 optionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#options. parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.WriterOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#
72 }
73
74 // Write writes a value to a byte slice.
75 func (j *xmlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#) Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#Write().(value *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) ([]byte, error) {
76 buf := new(bytesscip-go gomod github.com/golang/go/src go1.25 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25 bytes/Buffer#)
77 writer := xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.NewEncoderscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/NewEncoder().(buf)
78 defer func() {
79 _ = writer.Closescip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#Close().()
80 }()
81 if j.optionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#options..Compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#Compact. {
82 writer.Indentscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#Indent().("", "")
83 } else {
84 writer.Indentscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#Indent().("", " ")
85 }
86
87 element, err := j.toElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#toElement().("root", value)
88 if err != nil {
89 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to convert to element: %w", err)
90 }
91 for _, c := range element.Childrenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Children. {
92 c.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#compact. = j.optionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#options..Compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#Compact.
93 if err := writer.Encodescip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#Encode().(c); err != nil {
94 return nil, err
95 }
96 if !j.optionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#options..Compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#Compact. {
97 if err := writer.EncodeTokenscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#EncodeToken().(xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.CharDatascip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/CharData#("\n")); err != nil {
98 return nil, err
99 }
100 }
101 }
102
103 if err := writer.Flushscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#Flush().(); err != nil {
104 return nil, err
105 }
106 outBytes := buf.Bytesscip-go gomod github.com/golang/go/src go1.25 bytes/Buffer#Bytes().()
107 if !bytesscip-go gomod github.com/golang/go/src go1.25 bytes/.HasSuffixscip-go gomod github.com/golang/go/src go1.25 bytes/HasSuffix().(outBytes, []byte("\n")) {
108 outBytes = append(outBytes, '\n')
109 }
110 return outBytes, nil
111 }
112
113 func (j *xmlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#) toElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#toElement().(key string, value *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) (*xmlElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#, error) {
114 if !isValidXMLNamescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/isValidXMLName().(key) {
115 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("key %q is not a valid XML element name", key)
116 }
117 readProcessingInstructions := func() []*xmlProcessingInstructionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlProcessingInstruction# {
118 if piMeta, ok := value.MetadataValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#MetadataValue().("xml_processing_instructions"); ok && piMeta != nil {
119 if pis, ok := piMeta.([]*xmlProcessingInstructionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlProcessingInstruction#); ok {
120 return pis
121 }
122 }
123 return nil
124 }
125 readComments := func() []*xmlCommentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlComment# {
126 if commentMeta, ok := value.MetadataValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#MetadataValue().("xml_comments"); ok && commentMeta != nil {
127 if comments, ok := commentMeta.([]*xmlCommentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlComment#); ok {
128 return comments
129 }
130 }
131 return nil
132 }
133 switch value.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().() {
134
135 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeString.:
136 strVal, err := valueToStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/valueToString().(value)
137 return &xmlElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#{
138 Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Name.: key,
139 Contentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Content.: strVal,
140 ProcessingInstructionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#ProcessingInstructions.: readProcessingInstructions(),
141 Commentsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Comments.: readComments(),
142 }, err
143
144 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeMap.:
145 kvs, err := value.MapKeyValuesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#MapKeyValues().()
146 if err != nil {
147 return nil, err
148 }
149
150 el := &xmlElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#{
151 Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Name.: key,
152 ProcessingInstructionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#ProcessingInstructions.: readProcessingInstructions(),
153 Commentsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Comments.: readComments(),
154 }
155
156 if err := extractAttrsAndTextscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/extractAttrsAndText().(kvs, el); err != nil {
157 return nil, err
158 }
159
160 orderMeta, hasOrder := value.MetadataValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#MetadataValue().(xmlChildOrderKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlChildOrderKey.)
161 if hasOrder {
162 childOrder, ok := orderMeta.([]string)
163 if !ok {
164 hasOrder = false
165 } else {
166 if err := j.buildChildrenOrderedscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#buildChildrenOrdered().(kvs, el, childOrder); err != nil {
167 return nil, err
168 }
169 }
170 }
171
172 if !hasOrder {
173 if err := j.buildChildrenUnorderedscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#buildChildrenUnordered().(kvs, el); err != nil {
174 return nil, err
175 }
176 }
177
178 return el, nil
179 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeSlice.:
180 el := &xmlElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#{
181 Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Name.: "root",
182 ProcessingInstructionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#ProcessingInstructions.: readProcessingInstructions(),
183 Commentsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Comments.: readComments(),
184 useChildrenOnlyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#useChildrenOnly.: true,
185 }
186 if err := value.RangeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeSlice().(func(i int, value *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) error {
187 childEl, err := j.toElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#toElement().(key, value)
188 if err != nil {
189 return err
190 }
191 el.appendChildscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#appendChild().(childEl)
192
193 return nil
194 }); err != nil {
195 return nil, err
196 }
197 return el, nil
198 default:
199 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("xml writer does not support value type: %s", value.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().())
200 }
201 }
202
203 // extractAttrsAndText iterates kvs and extracts "-" prefixed attributes into
204 // el.Attrs and "#text" into el.Content.
205 func extractAttrsAndTextscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/extractAttrsAndText().(kvs []modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.KeyValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#, el *xmlElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#) error {
206 for _, kv := range kvs {
207 if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., "-") {
208 attrName := kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key.[1:]
209 if !isValidXMLNamescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/isValidXMLName().(attrName) {
210 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("invalid XML attribute name %q from map key %q", attrName, kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key.)
211 }
212 attr := xmlAttrscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlAttr#{
213 Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlAttr#Name.: attrName,
214 }
215 var err error
216 attr.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlAttr#Value., err = valueToStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/valueToString().(kv.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Value.)
217 if err != nil {
218 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to convert attribute %q to string: %w", attr.Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlAttr#Name., err)
219 }
220 el.Attrsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Attrs. = append(el.Attrsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Attrs., attr)
221 continue
222 }
223
224 if kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key. == "#text" {
225 var err error
226 el.Contentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Content., err = valueToStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/valueToString().(kv.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Value.)
227 if err != nil {
228 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to convert content to string: %w", err)
229 }
230 continue
231 }
232 }
233 return nil
234 }
235
236 // buildChildrenOrdered reconstructs child elements using counter-based ordering
237 // from the childOrder metadata slice.
238 func (j *xmlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#) buildChildrenOrderedscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#buildChildrenOrdered().(kvs []modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.KeyValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#, el *xmlElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#, childOrder []string) error {
239 // Build local map for fast lookups without GetMapKey overhead.
240 childValues := make(map[string]*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, len(kvs))
241 for _, kv := range kvs {
242 if !stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., "-") && kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key. != "#text" {
243 childValues[kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key.] = kv.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Value.
244 }
245 }
246
247 counters := make(map[string]int, len(childValues))
248 seen := make(map[string]bool, len(childValues))
249
250 for _, name := range childOrder {
251 seen[name] = true
252 childVal, exists := childValues[name]
253 if !exists {
254 // Key not in map (stale metadata after delete), skip.
255 counters[name]++
256 continue
257 }
258
259 index := counters[name]
260 counters[name]++
261
262 if childVal.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().() == modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeSlice. {
263 // SliceLen error is impossible after TypeSlice type check above.
264 sliceLen, _ := childVal.SliceLenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#SliceLen().()
265 if index >= sliceLen {
266 // Counter overflow (more metadata entries than actual values), skip.
267 continue
268 }
269 item, sliceErr := childVal.GetSliceIndexscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetSliceIndex().(index)
270 if sliceErr != nil {
271 // Should not happen after bounds check; skip gracefully if model is inconsistent.
272 continue
273 }
274 childEl, childErr := j.toElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#toElement().(name, item)
275 if childErr != nil {
276 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to convert child element %q to element: %w", name, childErr)
277 }
278 el.appendChildscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#appendChild().(childEl)
279 } else {
280 if index >= 1 {
281 // Scalar value, can only be emitted once.
282 continue
283 }
284 childEl, childErr := j.toElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#toElement().(name, childVal)
285 if childErr != nil {
286 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to convert child element %q to element: %w", name, childErr)
287 }
288 el.appendChildscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#appendChild().(childEl)
289 }
290 }
291
292 // Append any map keys not in the ordering (new keys from mutations).
293 for _, kv := range kvs {
294 if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., "-") || kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key. == "#text" || seen[kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key.] {
295 continue
296 }
297 childEl, childErr := j.toElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#toElement().(kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., kv.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Value.)
298 if childErr != nil {
299 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to convert child element %q to element: %w", kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., childErr)
300 }
301 el.appendChildscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#appendChild().(childEl)
302 }
303
304 return nil
305 }
306
307 // buildChildrenUnordered iterates map keys in insertion order, skipping
308 // attributes and #text (backward-compatible fallback).
309 func (j *xmlWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#) buildChildrenUnorderedscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#buildChildrenUnordered().(kvs []modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.KeyValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#, el *xmlElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#) error {
310 for _, kv := range kvs {
311 if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25 strings/HasPrefix().(kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., "-") || kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key. == "#text" {
312 continue
313 }
314 childEl, childErr := j.toElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlWriter#toElement().(kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., kv.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Value.)
315 if childErr != nil {
316 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to convert child element %q to element: %w", kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., childErr)
317 }
318 el.appendChildscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#appendChild().(childEl)
319 }
320 return nil
321 }
322
323 func valueToStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/valueToString().(v *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) (string, error) {
324 if v.IsNullscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IsNull().() {
325 return "", nil
326 }
327
328 switch v.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().() {
329 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeString.:
330 stringValue, err := v.StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().()
331 if err != nil {
332 return "", err
333 }
334 return stringValue, nil
335 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeInt.:
336 i, err := v.IntValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IntValue().()
337 if err != nil {
338 return "", err
339 }
340 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25 fmt/Sprintf().("%d", i), nil
341 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeFloatscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeFloat.:
342 i, err := v.FloatValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#FloatValue().()
343 if err != nil {
344 return "", err
345 }
346 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25 fmt/Sprintf().("%g", i), nil
347 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeBoolscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeBool.:
348 i, err := v.BoolValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#BoolValue().()
349 if err != nil {
350 return "", err
351 }
352 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25 fmt/Sprintf().("%t", i), nil
353 default:
354 return "", fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("xml writer cannot format type %s to string", v.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().())
355 }
356 }
357
358 // indentString returns the indentation for a given depth level.
359 func indentStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/indentString().(depth int) string {
360 return stringsscip-go gomod github.com/golang/go/src go1.25 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25 strings/Repeat().(" ", depth)
361 }
362
363 func (e *xmlElementscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#) MarshalXMLscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#MarshalXML().(enc *xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.Encoderscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#, start xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.StartElementscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/StartElement#) error {
364 // Write processing instructions before the element (document-level)
365 if len(e.ProcessingInstructionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#ProcessingInstructions.) > 0 {
366 for _, pi := range e.ProcessingInstructionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#ProcessingInstructions. {
367 if err := enc.EncodeTokenscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#EncodeToken().(xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.ProcInstscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/ProcInst#{
368 Targetscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/ProcInst#Target.: pi.Targetscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlProcessingInstruction#Target.,
369 Instscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/ProcInst#Inst.: []byte(pi.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlProcessingInstruction#Value.),
370 }); err != nil {
371 return err
372 }
373 if !e.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#compact. {
374 if err := enc.EncodeTokenscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#EncodeToken().(xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.CharDatascip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/CharData#("\n")); err != nil {
375 return err
376 }
377 }
378 }
379 }
380 // Write comments before the element (document-level comments only)
381 // Child-level comments are written by the parent inside its body
382 if e.depthscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#depth. == 0 && len(e.Commentsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Comments.) > 0 {
383 for _, comment := range e.Commentsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Comments. {
384 if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.Containsscip-go gomod github.com/golang/go/src go1.25 strings/Contains().(comment.Textscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlComment#Text., "--") {
385 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("comment text cannot contain '--' sequence (invalid XML comment)")
386 }
387 if err := enc.EncodeTokenscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#EncodeToken().(xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.Commentscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Comment#(comment.Textscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlComment#Text.)); err != nil {
388 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to encode comment: %w", err)
389 }
390 if !e.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#compact. {
391 if err := enc.EncodeTokenscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#EncodeToken().(xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.CharDatascip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/CharData#("\n")); err != nil {
392 return err
393 }
394 }
395 }
396 }
397 start.Namescip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/StartElement#Name. = xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.Namescip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Name#{Localscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Name#Local.: e.Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Name.}
398
399 if len(e.Attrsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Attrs.) > 0 {
400 for _, attr := range e.Attrsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Attrs. {
401 start.Attrscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/StartElement#Attr. = append(start.Attrscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/StartElement#Attr., xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.Attrscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Attr#{
402 Namescip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Attr#Name.: xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.Namescip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Name#{Localscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Name#Local.: attr.Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlAttr#Name.},
403 Valuescip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Attr#Value.: attr.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlAttr#Value.,
404 })
405 }
406 }
407
408 if err := enc.EncodeTokenscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#EncodeToken().(start); err != nil {
409 return err
410 }
411
412 // TODO : Handle CDATA sections on write.
413
414 if len(e.Contentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Content.) > 0 {
415 if err := enc.EncodeTokenscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#EncodeToken().(xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.CharDatascip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/CharData#(e.Contentscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Content.)); err != nil {
416 return err
417 }
418 }
419
420 // Write children with their preceding comments
421 childDepth := e.depthscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#depth. + 1
422 for _, child := range e.Childrenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Children. {
423 // Write child's comments inside parent, before the child element
424 if len(child.Commentsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Comments.) > 0 {
425 for _, comment := range child.Commentsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Comments. {
426 if stringsscip-go gomod github.com/golang/go/src go1.25 strings/.Containsscip-go gomod github.com/golang/go/src go1.25 strings/Contains().(comment.Textscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlComment#Text., "--") {
427 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("comment text cannot contain '--' sequence (invalid XML comment)")
428 }
429 if !e.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#compact. {
430 // Add newline + indentation before comment
431 if err := enc.EncodeTokenscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#EncodeToken().(xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.CharDatascip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/CharData#("\n" + indentStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/indentString().(childDepth))); err != nil {
432 return err
433 }
434 }
435 if err := enc.EncodeTokenscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#EncodeToken().(xmlscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/.Commentscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Comment#(comment.Textscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlComment#Text.)); err != nil {
436 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to encode comment: %w", err)
437 }
438 }
439 // Clear comments so child doesn't write them again
440 child.Commentsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#Comments. = nil
441 }
442 // Set child depth and compact flag for recursive calls
443 child.depthscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#depth. = childDepth
444 child.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#compact. = e.compactscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/xml`/xmlElement#compact.
445 if err := enc.Encodescip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#Encode().(child); err != nil {
446 return err
447 }
448 }
449
450 return enc.EncodeTokenscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/Encoder#EncodeToken().(start.Endscip-go gomod github.com/golang/go/src go1.25 `encoding/xml`/StartElement#End().())
451 }