MCPcopy
hub / github.com/qax-os/excelize / getRootElement

Function getRootElement

lib.go:653–679  ·  view source on GitHub ↗

getRootElement extract root element attributes by given XML decoder.

(d *xml.Decoder)

Source from the content-addressed store, hash-verified

651
652// getRootElement extract root element attributes by given XML decoder.
653func getRootElement(d *xml.Decoder) []xml.Attr {
654 tokenIdx := 0
655 for {
656 token, _ := d.Token()
657 if token == nil {
658 break
659 }
660 switch startElement := token.(type) {
661 case xml.StartElement:
662 tokenIdx++
663 if tokenIdx == 1 {
664 var ns bool
665 for i := 0; i < len(startElement.Attr); i++ {
666 if startElement.Attr[i].Value == NameSpaceSpreadSheet.Value &&
667 startElement.Attr[i].Name == NameSpaceSpreadSheet.Name {
668 ns = true
669 }
670 }
671 if !ns {
672 startElement.Attr = append(startElement.Attr, NameSpaceSpreadSheet)
673 }
674 return startElement.Attr
675 }
676 }
677 }
678 return nil
679}
680
681// genXMLNamespace generate serialized XML attributes with a multi namespace
682// by given element attributes.

Callers 3

workbookReaderMethod · 0.85
TestGetRootElementFunction · 0.85
workSheetReaderMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestGetRootElementFunction · 0.68