# HG changeset patch # User Sascha L. Teichmann # Date 1533638259 -7200 # Node ID b89138a25f9eb6f042935c03f0f1d32bacd36b2f # Parent 1ea90a22bd156492b337d223eb35971967507db7 Fixed namespace compression in WFS proxy. diff -r 1ea90a22bd15 -r b89138a25f9e controllers/externalwfs.go --- a/controllers/externalwfs.go Mon Aug 06 18:13:58 2018 +0200 +++ b/controllers/externalwfs.go Tue Aug 07 12:37:39 2018 +0200 @@ -171,7 +171,7 @@ return strings.Replace(s, from, to, -1) } - //var ns nsdef + var ns nsdef tokens: for { @@ -185,25 +185,31 @@ switch t := tok.(type) { case xml.StartElement: - //ns = ns.push() + ns = ns.push() t = t.Copy() attr := make([]xml.Attr, len(t.Attr)) - //var lns string for i, at := range t.Attr { switch { case at.Name.Space == "xmlns": - //ns.define(at.Value, at.Name.Local) - attr[i] = xml.Attr{Name: at.Name, Value: at.Value} - default: - attr[i] = xml.Attr{Name: at.Name, Value: replace(at.Value)} + ns.define(at.Value, at.Name.Local) + at.Name.Local = "xmlns:" + at.Name.Local + at.Name.Space = "" + + case at.Name.Space != "": + if s := ns.lookup(at.Name.Space); s != "" { + at.Name.Local = s + ":" + at.Name.Local + at.Name.Space = "" + } } + + attr[i] = at } - //if s := ns.lookup(t.Name.Space); s != "" { - // t.Name.Space = "" - // t.Name.Local = s + ":" + t.Name.Local - //} + if s := ns.lookup(t.Name.Space); s != "" { + t.Name.Space = "" + t.Name.Local = s + ":" + t.Name.Local + } t.Attr = attr tok = t @@ -211,13 +217,12 @@ tok = xml.CharData(replace(string(t))) case xml.EndElement: - //log.Printf("lookup %s -> %s\n", t.Name.Space, ns.lookup(t.Name.Space)) - //if s := ns.lookup(t.Name.Space); s != "" { - // t.Name.Space = "" - // t.Name.Local = s + ":" + t.Name.Local - // tok = t - // } - // ns = ns.pop() + if s := ns.lookup(t.Name.Space); s != "" { + t.Name.Space = "" + t.Name.Local = s + ":" + t.Name.Local + tok = t + } + ns = ns.pop() } if err := encoder.EncodeToken(tok); err != nil { return err