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

Method trim

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

trim updates the XML context to match the longest common prefix of the stack and the given parents. A closing tag will be written for every parent popped. Passing a zero slice or nil will close all the elements.

(parents []string)

Source from the content-addressed store, hash-verified

1074// and the given parents. A closing tag will be written for every parent
1075// popped. Passing a zero slice or nil will close all the elements.
1076func (s *parentStack) trim(parents []string) error {
1077 split := 0
1078 for ; split < len(parents) && split < len(s.stack); split++ {
1079 if parents[split] != s.stack[split] {
1080 break
1081 }
1082 }
1083 for i := len(s.stack) - 1; i >= split; i-- {
1084 if err := s.p.writeEnd(Name{Local: s.stack[i]}); err != nil {
1085 return err
1086 }
1087 }
1088 s.stack = s.stack[:split]
1089 return nil
1090}
1091
1092// push adds parent elements to the stack and writes open tags.
1093func (s *parentStack) push(parents []string) error {

Callers 1

marshalStructMethod · 0.80

Calls 1

writeEndMethod · 0.80

Tested by

no test coverage detected