Skip to content

[low] fix: [wifi_geolocation_kml] gx: prefix is used but never declared, so every KML is not namespace-well-formed - #254

Open
elhoim wants to merge 1 commit into
EC-DIGIT-CSIRC:mainfrom
elhoim:fix/kml-gx-namespace
Open

[low] fix: [wifi_geolocation_kml] gx: prefix is used but never declared, so every KML is not namespace-well-formed#254
elhoim wants to merge 1 commit into
EC-DIGIT-CSIRC:mainfrom
elhoim:fix/kml-gx-namespace

Conversation

@elhoim

@elhoim elhoim commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

BLUF

  • Priority: low in scope, but the output is completely unusable, not merely imperfect: every KML this analyser has ever produced fails to parse.
  • The gx: prefix is used but never declared. The root element declares only the default KML namespace, while five elements below use gx:gx:Tour, gx:Playlist, gx:FlyTo, gx:duration, gx:flyToMode.
  • This is not a validation nicety — it is a well-formedness error. An undeclared namespace prefix makes the document malformed, so a conforming parser refuses it outright. xml.etree.ElementTree.fromstring() on the current output raises ParseError: unbound prefix: line 2, column 54.
  • ElementTree will not catch this on the writing side. It treats "gx:Tour" as an opaque tag name and serialises it verbatim, so generation succeeds silently and the failure only appears when something tries to read the file — Google Earth, a KML library, or an analyst's own tooling.
  • Fix: declare xmlns:gx="http://www.google.com/kml/ext/2.2" — the standard Google KML extension namespace that these elements belong to — on the root element.
  • Scope: one element construction in wifi_geolocation_kml.py, plus a regression test.

Before

<kml xmlns="http://www.opengis.net/kml/2.2"><Document><gx:Tour>...
xml.etree.ElementTree.ParseError: unbound prefix: line 2, column 54

After

<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"><Document><gx:Tour>...

Parses cleanly; root tag resolves to {http://www.opengis.net/kml/2.2}kml.

Test

test_generated_kml_is_namespace_well_formed generates a KML from a one-network input and runs ET.fromstring() over it, asserting the root tag resolves in the KML namespace and the gx namespace URI is present.

Verified to fail on main with ParseError: unbound prefix and pass with this change. The existing test_analyse_wifi_geolocation_kml only asserts the output file is non-empty, so it is unaffected.

…element

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@elhoim
elhoim force-pushed the fix/kml-gx-namespace branch from d89d355 to 16f4973 Compare September 9, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant