https://github.com/amandasaurus/anglosaxon-python
Command line SAX parser builder
https://github.com/amandasaurus/anglosaxon-python
Last synced: about 1 month ago
JSON representation
Command line SAX parser builder
- Host: GitHub
- URL: https://github.com/amandasaurus/anglosaxon-python
- Owner: amandasaurus
- License: gpl-3.0
- Created: 2012-01-01T18:57:45.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2012-01-02T15:12:50.000Z (almost 14 years ago)
- Last Synced: 2024-12-27T00:24:39.984Z (12 months ago)
- Language: Python
- Homepage:
- Size: 105 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Anglosaxon is a command line tool to parse XML files using SAX. It is designed to do simple transformations of XML files into other textual formats in a streaming format.
# Example Usage
cat changesets.osm | anglosaxon.py -s changeset -o "changeset id=" -v id --nl
# Documention
``anglosaxon`` reads an xml file from stdin and writes things to stdout.
Arguments are of the form ``-s TAGNAME INSTRUCTIONS`` or ``-e TAGNAME INSTRUCTIONS``. ``-s TAGNAME`` means 'output this text when you see the open tag for TAGNAME'. ``INSTRUCTIONS`` is one or more of ``-v ATTRIBUTENAME``, ``-o RAWSTRING``, ``-V ATTRIBUTENAME DEFAULT`` or ``--nl``.
* ``-o RAWSTRING``: Output RAWSTRING
* ``-v ATTRIBUTENAME``: output the attribute ATTRIBUTENAME. An error is thrown if it doesn't exist. Short for 'value'.
* ``-V ATTRIBUTENAME DEFAULT``: output the attribute ATTRIBUTENAME (like ``-v``), but if the attribute isn't there, output DEFAULTVALUE
* ``--nl``: output a new line (``\n``), short for ``-o "\n"``.
TAGNAME can be a raw tag, like ``foo``, or it can include relative tag names, like ``bar/foo`` (to match any foo tag that's a child of a bar tag), or ``/osm/node`` (to match any node tag that's a child of an osm tag, which is a child of the root).
Likewise ``-e TAGNAME`` outputs text when it sees the end tag