Mercurial > gemma
changeset 351:b89138a25f9e
Fixed namespace compression in WFS proxy.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 07 Aug 2018 12:37:39 +0200 |
parents | 1ea90a22bd15 |
children | 23d4a9104b0c |
files | controllers/externalwfs.go |
diffstat | 1 files changed, 23 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- 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