-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Parser minor modifications -Schema checking example file -Schema checking documentation [ci skip]
- Loading branch information
1 parent
ea576ea
commit 775d14f
Showing
7 changed files
with
113 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ Tutorials | |
parsing.rst | ||
plotting.rst | ||
modifying.rst | ||
writing.rst | ||
writing.rst | ||
schemas.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Checking Schemas | ||
---------------- | ||
|
||
There are tree ways to check if a GPX file follows the XML schemas. | ||
In all cases, the GPX file will be checked for the relevant Topographix GPX schema (either version 1.0 or 1.1). | ||
If the :py:arg:`~extensions_schemas` is set to :py:val:`~True`, then the GPX file will be tested for all schemas that are listed. | ||
|
||
During Parsing | ||
^^^^^^^^^^^^^^ | ||
|
||
It is possible to check during parsing, in which case an invalid GPX file will raise an error. | ||
|
||
:: | ||
|
||
import ezgpx | ||
|
||
# Check GPX schema when parsing file | ||
gpx = ezgpx.GPX("file.gpx", check_schemas=True, extensions_schemas=False) | ||
|
||
Test a :py:class:`~ezgpx.gpx.GPX` Object | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
A :py:class:`~ezgpx.gpx.GPX` object can directly be checked. | ||
|
||
:: | ||
|
||
import ezgpx | ||
|
||
gpx = GPX("file.gpx", check_schemas=False) | ||
|
||
# Check GPX schema and extensions schemas from GPX instance | ||
gpx.check_schemas(extensions_schemas=True) | ||
|
||
After Writting | ||
^^^^^^^^^^^^^^ | ||
|
||
It is possible to check whether a written GPX file follows XML schemas. | ||
|
||
:: | ||
|
||
import ezgpx | ||
|
||
gpx = GPX("file.gpx", check_schemas=False) | ||
|
||
# Check if written file follow GPX schema | ||
if gpx.to_gpx("new_file.gpx", check_schemas=True, extensions_schemas=False) == False: | ||
print("new_file.gpx does not follow the GPX 1.1 schema!!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import ezgpx | ||
|
||
# Check GPX schema when parsing file | ||
gpx = ezgpx.GPX("file.gpx", check_schemas=True, extensions_schemas=False) | ||
|
||
# Check GPX schema and extensions schemas from GPX instance | ||
gpx.check_schemas(extensions_schemas=True) | ||
|
||
# Check if written file follow GPX schema | ||
gpx.to_gpx("new_file.gpx", check_schemas=True, extensions_schemas=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters