MCPcopy Index your code
hub / github.com/XmirrorSecurity/OpenSCA-cli / unmarshalTextInterface

Method unmarshalTextInterface

opensca/sca/java/xml/read.go:228–248  ·  view source on GitHub ↗

unmarshalTextInterface unmarshals a single XML element into val. The chardata contained in the element (but not its children) is passed to the text unmarshaler.

(val encoding.TextUnmarshaler)

Source from the content-addressed store, hash-verified

226// The chardata contained in the element (but not its children)
227// is passed to the text unmarshaler.
228func (d *Decoder) unmarshalTextInterface(val encoding.TextUnmarshaler) error {
229 var buf []byte
230 depth := 1
231 for depth > 0 {
232 t, err := d.Token()
233 if err != nil {
234 return err
235 }
236 switch t := t.(type) {
237 case CharData:
238 if depth == 1 {
239 buf = append(buf, t...)
240 }
241 case StartElement:
242 depth++
243 case EndElement:
244 depth--
245 }
246 }
247 return val.UnmarshalText(buf)
248}
249
250// unmarshalAttr unmarshals a single XML attribute into val.
251func (d *Decoder) unmarshalAttr(val reflect.Value, attr Attr) error {

Callers 1

unmarshalMethod · 0.95

Calls 1

TokenMethod · 0.95

Tested by

no test coverage detected