MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / marshalInterface

Method marshalInterface

opensca/sca/java/xml/marshal.go:680–697  ·  view source on GitHub ↗

marshalInterface marshals a Marshaler interface value.

(val Marshaler, start StartElement)

Source from the content-addressed store, hash-verified

678
679// marshalInterface marshals a Marshaler interface value.
680func (p *printer) marshalInterface(val Marshaler, start StartElement) error {
681 // Push a marker onto the tag stack so that MarshalXML
682 // cannot close the XML tags that it did not open.
683 p.tags = append(p.tags, Name{})
684 n := len(p.tags)
685
686 err := val.MarshalXML(p.encoder, start)
687 if err != nil {
688 return err
689 }
690
691 // Make sure MarshalXML closed all its tags. p.tags[n-1] is the mark.
692 if len(p.tags) > n {
693 return fmt.Errorf("xml: %s.MarshalXML wrote invalid XML: <%s> not closed", receiverType(val), p.tags[len(p.tags)-1].Local)
694 }
695 p.tags = p.tags[:n-1]
696 return nil
697}
698
699// marshalTextInterface marshals a TextMarshaler interface value.
700func (p *printer) marshalTextInterface(val encoding.TextMarshaler, start StartElement) error {

Callers 1

marshalValueMethod · 0.95

Calls 2

receiverTypeFunction · 0.85
MarshalXMLMethod · 0.80

Tested by

no test coverage detected