MCPcopy Create free account
hub / github.com/crewjam/saml / elementWithNamespaces

Function elementWithNamespaces

service_provider.go:3832–3854  ·  view source on GitHub ↗

elementWithNamespaces returns a copy of el that declares every namespace prefix it inherits from its ancestors.

(el *etree.Element)

Source from the content-addressed store, hash-verified

3830// elementWithNamespaces returns a copy of el that declares every namespace
3831// prefix it inherits from its ancestors.
3832func elementWithNamespaces(el *etree.Element) *etree.Element {
3833 root := el.Copy()
3834
3835 declared := map[string]bool{}
3836 for _, attr := range root.Attr {
3837 if prefix, ok := namespaceDeclPrefix(attr); ok {
3838 declared[prefix] = true
3839 }
3840 }
3841
3842 // Walk outward so the nearest declaration of each prefix wins.
3843 for p := el.Parent(); p != nil; p = p.Parent() {
3844 for _, attr := range p.Attr {
3845 prefix, ok := namespaceDeclPrefix(attr)
3846 if !ok || declared[prefix] {
3847 continue
3848 }
3849 declared[prefix] = true
3850 root.CreateAttr(attr.FullKey(), attr.Value)
3851 }
3852 }
3853 return root
3854}
3855
3856func elementCopyToBytes(root *etree.Element) ([]byte, error) {
3857 doc := etree.NewDocument()

Callers 2

elementToBytesFunction · 0.85
unmarshalElementFunction · 0.85

Calls 1

namespaceDeclPrefixFunction · 0.85

Tested by

no test coverage detected