Skip to content

Commit

Permalink
add additional namespace example
Browse files Browse the repository at this point in the history
  • Loading branch information
kb0 committed May 10, 2024
1 parent ccbc9eb commit 426a6e9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/assets/namespace.gpx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="dart-gpx library" xmlns:trp="http://www.garmin.com/xmlschemas/TripExtensions/v1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<wpt lat="1.0" lon="1.0">
<fix>2d</fix>
</wpt>
<wpt lat="1.0" lon="1.0">
<fix>3d</fix>
</wpt>
<wpt lat="1.0" lon="1.0">
<fix>none</fix>
</wpt>
</gpx>
15 changes: 15 additions & 0 deletions test/gpx_writer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,19 @@ void main() {

expectXml(GpxWriter().asString(gpx, pretty: true), xml);
});

test('write custom namespaces', () async {
final gpx = createMinimalGPX();
gpx.wpts = [
Wpt(lat: 1, lon: 1, fix: FixType.fix_2d),
Wpt(lat: 1, lon: 1, fix: FixType.fix_3d),
Wpt(lat: 1, lon: 1, fix: FixType.none)
];
final xml = await File('test/assets/namespace.gpx').readAsString();

final gpxXml = GpxWriter().asXml(gpx);
gpxXml.children[1].setAttribute("xmlns:trp", "http://www.garmin.com/xmlschemas/TripExtensions/v1");
gpxXml.children[1].setAttribute("xsi:schemaLocation", "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
expectXml(gpxXml.toXmlString(), xml);
});
}

0 comments on commit 426a6e9

Please sign in to comment.