summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Kislyuk <kislyuk@gmail.com>2018-02-08 11:56:56 -0800
committerAndrey Kislyuk <kislyuk@gmail.com>2018-02-08 11:56:56 -0800
commit81e01110683c3dce7105c3a461a1eba8b291ce45 (patch)
tree6e162aef7204a05b82861f66263877ffe9e6b102
parent5e0f21ef97ef965acb61827f85520c5b8868504e (diff)
-rw-r--r--README.rst11
-rwxr-xr-xyq/__init__.py2
2 files changed, 10 insertions, 3 deletions
diff --git a/README.rst b/README.rst
index 827e624..67be9c7 100644
--- a/README.rst
+++ b/README.rst
@@ -1,5 +1,5 @@
-yq: Command-line YAML processor - jq wrapper for YAML documents
-===============================================================
+yq: Command-line YAML/XML processor - jq wrapper for YAML and XML documents
+===========================================================================
Installation
------------
@@ -34,6 +34,13 @@ All other command line arguments are forwarded to ``jq``. ``yq`` forwards the ex
unless there was an error in YAML parsing, in which case the exit code is 1. See the `jq manual
<https://stedolan.github.io/jq/manual/>`_ for more details on ``jq`` features and options.
+XML support
+-----------
+``yq`` also supports XML. The ``yq`` package installs an executable, ``xq``, which
+`transcodes XML to JSON <https://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html>`_ using
+`xmltodict <https://github.com/martinblech/xmltodict>`_ and pipes it to ``jq``. Roundtrip transcoding is available with
+the ``xq -x`` option. Multiple XML documents can be passed in separate files/streams as ``xq a.xml b.xml``.
+
.. admonition:: Compatibility note
This package's release series available on PyPI begins with version 2.0.0. Versions of ``yq`` prior to 2.0.0 are
diff --git a/yq/__init__.py b/yq/__init__.py
index 180e9de..1b558d6 100755
--- a/yq/__init__.py
+++ b/yq/__init__.py
@@ -120,7 +120,7 @@ def main(args=None, input_format="yaml"):
elif args.xml_output:
import xmltodict
for doc in decode_docs(jq_out, json_decoder):
- xmltodict.unparse(doc, output=sys.stdout)
+ xmltodict.unparse(doc, output=sys.stdout, full_document=False, pretty=True, indent=" ")
sys.stdout.write(b"\n" if sys.version_info < (3, 0) else "\n")
else:
if input_format == "yaml":