├── .editorconfig ├── .github ├── dependabot.yml └── workflows │ └── build.yaml ├── .gitignore ├── .readthedocs.yaml ├── AUTHORS.rst ├── CONTRIBUTING.rst ├── HISTORY.rst ├── LICENSE ├── MANIFEST.in ├── README.rst ├── docs ├── authors.rst ├── conf.py ├── contributing.rst ├── history.rst ├── index.rst ├── installation.rst ├── readme.rst └── usage.rst ├── requirements.txt ├── requirements_dev.txt ├── setup.cfg ├── setup.py ├── tasks.py ├── tests ├── test.rng ├── test.xml ├── test.xslt ├── test2.xml └── test_xmlstarlet.py ├── tox.ini ├── xmlstarlet ├── AUTHORS ├── COPYING ├── ChangeLog ├── Copyright ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── TODO ├── __init__.py ├── configure.ac ├── doc │ ├── doc.mk │ ├── gen-doc │ ├── html.css │ ├── replace-PROG-VERSION.xsl │ ├── xmlstar-fodoc-style.xsl │ ├── xmlstarlet-man.xml │ ├── xmlstarlet-ug.html │ ├── xmlstarlet-ug.pdf │ ├── xmlstarlet-ug.ps │ ├── xmlstarlet-ug.xml │ ├── xmlstarlet.1 │ └── xmlstarlet.txt ├── examples │ ├── N-order │ ├── bigxml │ ├── bigxml-dtd │ ├── bigxml-embed │ ├── bigxml-embed-ref │ ├── bigxml-relaxng │ ├── bigxml-well-formed │ ├── bigxml-xsd │ ├── c14n-default-attr │ ├── c14n-newlines │ ├── c14n1 │ ├── c14n2 │ ├── command-help │ ├── count1 │ ├── countnode1 │ ├── delete1 │ ├── docbook1 │ ├── dtd │ │ ├── bigxml.dtd │ │ ├── tab-obj.dtd │ │ └── table.dtd │ ├── dtd1 │ ├── dtd2 │ ├── dtd3 │ ├── dtd4 │ ├── ed-2op │ ├── ed-append │ ├── ed-backref-delete │ ├── ed-backref1 │ ├── ed-backref2 │ ├── ed-expr │ ├── ed-insert │ ├── ed-literal │ ├── ed-move │ ├── ed-namespace │ ├── ed-nop │ ├── ed-subnode │ ├── elem-depth │ ├── elem-uniq │ ├── elem1 │ ├── elem2 │ ├── elem3 │ ├── escape1 │ ├── exslt-ed │ ├── exslt1 │ ├── findfile1 │ ├── foreach-literal.sh │ ├── foreach-xpath.sh │ ├── genxml1 │ ├── hello1 │ ├── html │ │ └── hello1.html │ ├── j2ee │ │ └── web.xml │ ├── localname1 │ ├── look1 │ ├── move1 │ ├── noindent1 │ ├── ns1 │ ├── pyx │ ├── pyx-ns │ ├── rdf │ │ └── em.rdf │ ├── recover1 │ ├── relaxng │ │ ├── address-bad.xml │ │ ├── address.rng │ │ ├── address.xml │ │ └── bigxml.rng │ ├── rename-attr1 │ ├── rename-elem1 │ ├── results │ │ ├── N-order.out │ │ ├── bigxml-dtd.out │ │ ├── bigxml-embed-ref.out │ │ ├── bigxml-embed.out │ │ ├── bigxml-relaxng.out │ │ ├── bigxml-well-formed.out │ │ ├── bigxml-xsd.out │ │ ├── bigxml.out │ │ ├── c14n-default-attr.out │ │ ├── c14n-newlines.out │ │ ├── c14n1.out │ │ ├── c14n2.out │ │ ├── command-help.out │ │ ├── count1.out │ │ ├── countnode1.out │ │ ├── delete1.out │ │ ├── docbook1.out │ │ ├── dtd1.out │ │ ├── dtd2.out │ │ ├── dtd3.out │ │ ├── dtd4.out │ │ ├── ed-2op.out │ │ ├── ed-append.out │ │ ├── ed-backref-delete.out │ │ ├── ed-backref1.out │ │ ├── ed-backref2.out │ │ ├── ed-expr.out │ │ ├── ed-insert.out │ │ ├── ed-literal.out │ │ ├── ed-move.out │ │ ├── ed-namespace.out │ │ ├── ed-nop.out │ │ ├── ed-subnode.out │ │ ├── elem-depth.out │ │ ├── elem-uniq.out │ │ ├── elem1.out │ │ ├── elem2.out │ │ ├── elem3.out │ │ ├── escape1.out │ │ ├── exslt-ed.out │ │ ├── exslt1.out │ │ ├── external-entity.out │ │ ├── findfile1.out │ │ ├── genxml1.out │ │ ├── hello1.out │ │ ├── localname1.out │ │ ├── look1.out │ │ ├── move1.out │ │ ├── noindent1.out │ │ ├── ns1.out │ │ ├── pyx-ns.out │ │ ├── pyx.out │ │ ├── recover1.out │ │ ├── rename-attr1.out │ │ ├── rename-elem1.out │ │ ├── schema1.out │ │ ├── sel-if.out │ │ ├── sel-literal.out │ │ ├── sel-many-values.out │ │ ├── sel-root.out │ │ ├── sel-xpath-c.out │ │ ├── sel-xpath-i.out │ │ ├── sel-xpath-m.out │ │ ├── sel-xpath-v.out │ │ ├── sel1.out │ │ ├── sort1.out │ │ ├── sort2.out │ │ ├── sort3.out │ │ ├── structure1.out │ │ ├── sum1.out │ │ ├── tab1.out │ │ ├── table1.out │ │ ├── table2.out │ │ ├── table3.out │ │ ├── tree1.out │ │ ├── unicode1.out │ │ ├── update-attr1.out │ │ ├── update-elem1.out │ │ ├── valid1.out │ │ ├── xinclude1.out │ │ ├── xsl-param1.out │ │ └── xsl-sum1.out │ ├── schema1 │ ├── sel-if │ ├── sel-literal │ ├── sel-many-values │ ├── sel-root │ ├── sel-xpath-c │ ├── sel-xpath-i │ ├── sel-xpath-m │ ├── sel-xpath-v │ ├── sel1 │ ├── sgml │ │ └── docbook1.sgml │ ├── sort1 │ ├── sort2 │ ├── sort3 │ ├── structure1 │ ├── sum1 │ ├── svg │ │ └── sample.svg │ ├── tab1 │ ├── table1 │ ├── table2 │ ├── table3 │ ├── tests.mk │ ├── tree1 │ ├── unicode1 │ ├── update-attr1 │ ├── update-elem1 │ ├── valid1 │ ├── vxml │ │ └── root.vxml │ ├── wsdl │ │ └── quote.wsdl │ ├── xinclude1 │ ├── xmi │ │ └── example.xmi │ ├── xml │ │ ├── S0.xml │ │ ├── books.xml │ │ ├── c14n-default-attr.xml │ │ ├── c14n.xml │ │ ├── c14n.xpath │ │ ├── disclaimer.xml │ │ ├── document.xml │ │ ├── entity.xml │ │ ├── external-pe.xml │ │ ├── foo.dtd │ │ ├── foo.xml │ │ ├── malformed.xml │ │ ├── structure.xml │ │ ├── tab-bad.xml │ │ ├── tab-obj.xml │ │ ├── table.xml │ │ ├── unicode.xml │ │ ├── unsorted.xml │ │ ├── xmlstarlet-pad.xml │ │ └── xmlstarlet-xsa.xml │ ├── xmlstarlet │ ├── xmlstarlet.msys │ ├── xsd │ │ ├── bigxml.xsd │ │ └── table.xsd │ ├── xsl-param1 │ ├── xsl-sum1 │ ├── xsl │ │ ├── cat.xsl │ │ ├── hello1.xsl │ │ ├── param1.xsl │ │ └── sum1.xsl │ ├── xsp │ │ └── dynamic.xsp │ ├── xsql │ │ └── jobserve.xsql │ └── xupdate │ │ └── insxml.xup ├── m4 │ ├── quiet-rule.m4 │ └── xstar-check-libs.m4 ├── no-exit.patch ├── setup_msvc.bat ├── solaris │ └── package │ │ ├── sol8-sparc │ │ ├── build │ │ ├── pkginfo.in │ │ └── prototype │ │ └── sol9-sparc │ │ ├── build │ │ ├── pkginfo.in │ │ └── prototype ├── src │ ├── c14n-usage.txt │ ├── depyx-usage.txt │ ├── edit-usage.txt │ ├── elem-usage.txt │ ├── escape-usage.txt │ ├── escape.h │ ├── format-usage.txt │ ├── ls-usage.txt │ ├── pyx-usage.txt │ ├── select-usage.txt │ ├── sources.mk │ ├── trans-usage.txt │ ├── trans.c │ ├── trans.h │ ├── unescape-usage.txt │ ├── usage.txt │ ├── validate-usage.txt │ ├── xml.c │ ├── xml_C14N.c │ ├── xml_depyx.c │ ├── xml_edit.c │ ├── xml_elem.c │ ├── xml_escape.c │ ├── xml_format.c │ ├── xml_ls.c │ ├── xml_pyx.c │ ├── xml_select.c │ ├── xml_trans.c │ ├── xml_validate.c │ └── xmlstar.h ├── tests │ ├── runAllTests.sh │ └── runTest.sh ├── usage2c.awk ├── win32 │ ├── Makefile.msvc │ ├── configure.js │ ├── usage_gen.cmd │ ├── win32_xml_ls.c │ └── win32config.h └── xmlstarlet.spec.in └── xmlstarlet_build.py /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | charset = utf-8 11 | end_of_line = lf 12 | 13 | [*.bat] 14 | indent_style = tab 15 | end_of_line = crlf 16 | 17 | [LICENSE] 18 | insert_final_newline = false 19 | 20 | [Makefile] 21 | indent_style = tab 22 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "pip" 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | - package-ecosystem: "github-actions" 13 | # Workflow files stored in the 14 | # default location of `.github/workflows` 15 | directory: "/" 16 | schedule: 17 | interval: "weekly" 18 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | # Automatically build binary wheels and source packages. 2 | name: cibuildwheel 3 | 4 | # Build on every branch push, tag push, and pull request change: 5 | on: [push, pull_request] 6 | 7 | # Do not build Python <=2.7, <=3.5, or PyPy. 8 | # Install Linux and MacOS required libraries / tools. 9 | env: 10 | CIBW_PROJECT_REQUIRES_PYTHON: ">=3.6" 11 | CIBW_SKIP: "cp27-* cp35-* pp*" 12 | CIBW_TEST_REQUIRES: pytest 13 | CIBW_TEST_COMMAND: "pytest {project}" 14 | CIBW_DEPENDENCY_VERSIONS: "pinned" 15 | CIBW_ARCHS: auto 16 | 17 | jobs: 18 | build_wheels: 19 | name: Build wheels on ${{ matrix.os }} 20 | runs-on: ${{ matrix.os }} 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | os: [ubuntu-20.04, windows-2019, macOS-10.15] 25 | 26 | steps: 27 | - name: Checkout sources 28 | uses: actions/checkout@v3 29 | 30 | - name: Prepare Windows x86 builds 31 | uses: ilammy/msvc-dev-cmd@v1 32 | with: 33 | toolset: "14.0" 34 | arch: "x86" 35 | 36 | - name: Build Windows x86 wheels 37 | if: runner.os == 'Windows' 38 | uses: pypa/cibuildwheel@v2.11.2 39 | env: 40 | CIBW_BUILD: "*win32" 41 | CIBW_BEFORE_BUILD_WINDOWS: "call xmlstarlet\\setup_msvc.bat" 42 | CIBW_ENVIRONMENT_WINDOWS: > 43 | CIBW_ARCHS_WINDOWS=auto32 44 | PLATFORM_NAME=x86 45 | DISTUTILS_USE_SDK=1 46 | MSSdk=1 47 | with: 48 | package-dir: . 49 | output-dir: wheelhouse 50 | 51 | - name: Prepare Windows x64 builds 52 | uses: ilammy/msvc-dev-cmd@v1 53 | with: 54 | toolset: "14.0" 55 | arch: "x64" 56 | 57 | - name: Build Windows x86 wheels 58 | if: runner.os == 'Windows' 59 | uses: pypa/cibuildwheel@v2.11.2 60 | env: 61 | CIBW_BUILD: "*win_amd64" 62 | CIBW_BEFORE_BUILD_WINDOWS: "call xmlstarlet\\setup_msvc.bat" 63 | CIBW_ENVIRONMENT_WINDOWS: > 64 | CIBW_ARCHS_WINDOWS=auto64 65 | PLATFORM_NAME=amd64 66 | DISTUTILS_USE_SDK=1 67 | MSSdk=1 68 | with: 69 | package-dir: . 70 | output-dir: wheelhouse 71 | 72 | - name: Build Linux and MacOS wheels 73 | if: runner.os != 'Windows' 74 | uses: pypa/cibuildwheel@v2.11.2 75 | env: 76 | CIBW_SKIP: "*win*" 77 | CIBW_BEFORE_ALL_LINUX: > 78 | yum install -y libxslt-devel || 79 | apt-get -y install libxslt1-dev libxml2-dev || 80 | apk add libxml2-dev libxslt-dev 81 | CIBW_BEFORE_ALL_MACOS: > 82 | brew uninstall --force --ignore-dependencies libxml2 libxslt libffi && 83 | brew cleanup -s libxml2 libxslt libffi && 84 | brew cleanup --prune-prefix && 85 | brew install libxml2 libxslt automake pkg-config 86 | CIBW_ENVIRONMENT_MACOS: > 87 | ARCHFLAGS="-arch x86_64" 88 | PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/libxslt/lib/pkgconfig" 89 | LDFLAGS="-L/usr/local/opt/libxml2/lib -L/usr/local/opt/libxslt/lib" 90 | CPPFLAGS="-I/usr/local/opt/libxml2/include -I/usr/local/opt/libxslt/include -I/usr/local/opt/libffi/include" 91 | PATH="/usr/local/opt/libxslt/bin:/usr/local/opt/libxml2/bin:$PATH" 92 | with: 93 | package-dir: . 94 | output-dir: wheelhouse 95 | 96 | - uses: actions/upload-artifact@v3 97 | with: 98 | path: ./wheelhouse/*.whl 99 | 100 | build_sdist_and_test: 101 | name: Build source distribution 102 | runs-on: ubuntu-latest 103 | steps: 104 | - uses: actions/checkout@v3 105 | 106 | - uses: actions/setup-python@v4 107 | name: Install Python 108 | with: 109 | python-version: '3.7' 110 | 111 | - name: Build sdist and run tests 112 | run: | 113 | sudo apt-get install -yqq libxslt1-dev libxml2-dev 114 | pip install --upgrade pip setuptools wheel "cibuildwheel>=2.8.1" 115 | pip --disable-pip-version-check install -r requirements.txt 116 | pip --disable-pip-version-check install -r requirements_dev.txt 117 | invoke test coverage 118 | 119 | - uses: actions/upload-artifact@v3 120 | with: 121 | path: dist/*.tar.gz 122 | 123 | upload_pypi: 124 | needs: [build_wheels, build_sdist_and_test] 125 | runs-on: ubuntu-latest 126 | # upload to PyPI on every tag starting with 'v' 127 | if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') 128 | steps: 129 | - uses: actions/download-artifact@v3 130 | with: 131 | name: artifact 132 | path: dist 133 | 134 | - uses: pypa/gh-action-pypi-publish@master 135 | with: 136 | user: __token__ 137 | password: ${{ secrets.pypi_password }} 138 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | xmlstarlet/_xmlstarlet.* 9 | xmlstar/config.h.in~ 10 | xmlstarlet/xml 11 | xmlstarlet/Makefile 12 | xmlstarlet/config.status 13 | xmlstarlet/config.h 14 | xmlstarlet/Makefile.in 15 | xmlstarlet/aclocal.m4 16 | xmlstarlet/compile 17 | xmlstarlet/config.guess 18 | xmlstarlet/config.sub 19 | xmlstarlet/configure 20 | xmlstarlet/depcomp 21 | xmlstarlet/install-sh 22 | xmlstarlet/missing 23 | xmlstarlet/test-driver 24 | xmlstarlet/version.h 25 | xmlstarlet/src/.dirstamp 26 | xmlstarlet/src/c14n-usage.c 27 | xmlstarlet/src/depyx-usage.c 28 | xmlstarlet/src/edit-usage.c 29 | xmlstarlet/src/elem-usage.c 30 | xmlstarlet/src/escape-usage.c 31 | xmlstarlet/src/format-usage.c 32 | xmlstarlet/src/ls-usage.c 33 | xmlstarlet/src/pyx-usage.c 34 | xmlstarlet/src/select-usage.c 35 | xmlstarlet/src/trans-usage.c 36 | xmlstarlet/src/unescape-usage.c 37 | xmlstarlet/src/usage.c 38 | xmlstarlet/src/validate-usage.c 39 | xmlstarlet/stamp-h1 40 | .ccls-cache/** 41 | **/*.o 42 | **/*.trs 43 | **/autom4te.cache/ 44 | **/*/.deps/ 45 | **/solaris/package/*/pkginfo 46 | xmlstarlet/solaris/package/sol8-sparc/pkginfo 47 | xmlstarlet/solaris/package/sol9-sparc/pkginfo 48 | **/version.h 49 | 50 | 51 | # Distribution / packaging 52 | .Python 53 | env/ 54 | build/ 55 | develop-eggs/ 56 | dist/ 57 | downloads/ 58 | eggs/ 59 | .eggs/ 60 | lib/ 61 | lib64/ 62 | parts/ 63 | sdist/ 64 | var/ 65 | wheels/ 66 | *.egg-info/ 67 | .installed.cfg 68 | *.egg 69 | 70 | # PyInstaller 71 | # Usually these files are written by a python script from a template 72 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 73 | *.manifest 74 | *.spec 75 | 76 | # Installer logs 77 | pip-log.txt 78 | pip-delete-this-directory.txt 79 | 80 | # Unit test / coverage reports 81 | htmlcov/ 82 | .tox/ 83 | .coverage 84 | .coverage.* 85 | .cache 86 | nosetests.xml 87 | coverage.xml 88 | *.cover 89 | .hypothesis/ 90 | .pytest_cache/ 91 | 92 | # Translations 93 | *.mo 94 | *.pot 95 | 96 | # Django stuff: 97 | *.log 98 | local_settings.py 99 | 100 | # Flask stuff: 101 | instance/ 102 | .webassets-cache 103 | 104 | # Scrapy stuff: 105 | .scrapy 106 | 107 | # Sphinx documentation 108 | docs/_build/ 109 | 110 | # PyBuilder 111 | target/ 112 | 113 | # Jupyter Notebook 114 | .ipynb_checkpoints 115 | 116 | # pyenv 117 | .python-version 118 | 119 | # celery beat schedule file 120 | celerybeat-schedule 121 | 122 | # SageMath parsed files 123 | *.sage.py 124 | 125 | # dotenv 126 | .env 127 | 128 | # virtualenv 129 | .venv 130 | venv/ 131 | ENV/ 132 | 133 | # Spyder project settings 134 | .spyderproject 135 | .spyproject 136 | 137 | # Rope project settings 138 | .ropeproject 139 | 140 | # mkdocs documentation 141 | /site 142 | 143 | # mypy 144 | .mypy_cache/ 145 | 146 | xmlstarlet/config.h* 147 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | version: 2 6 | 7 | build: 8 | image: latest 9 | 10 | sphinx: 11 | builder: html 12 | configuration: docs/conf.py 13 | 14 | formats: 15 | - epub 16 | - pdf 17 | 18 | python: 19 | version: 3.7 20 | install: 21 | - requirements: requirements.txt 22 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | XMLStarlet Developers 6 | --------------------- 7 | 8 | * Mikhail Grushinskiy 9 | * Dagobert Michelsen 10 | * Noam Postavsky 11 | 12 | XMLStarlet CFFI Python Bindings Maintainer 13 | ------------------------------------------ 14 | 15 | * Dimiter Naydenov 16 | 17 | Contributors 18 | ------------ 19 | 20 | None yet. Why not be the first? 21 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Contributing 5 | ============ 6 | 7 | Contributions are welcome, and they are greatly appreciated! Every little bit 8 | helps, and credit will always be given. 9 | 10 | You can contribute in many ways: 11 | 12 | Types of Contributions 13 | ---------------------- 14 | 15 | Report Bugs 16 | ~~~~~~~~~~~ 17 | 18 | Report bugs at https://github.com/dimitern/xmlstarlet/issues. 19 | 20 | If you are reporting a bug, please include: 21 | 22 | * Your operating system name and version. 23 | * Any details about your local setup that might be helpful in troubleshooting. 24 | * Detailed steps to reproduce the bug. 25 | 26 | Fix Bugs 27 | ~~~~~~~~ 28 | 29 | Look through the GitHub issues for bugs. Anything tagged with "bug" and "help 30 | wanted" is open to whoever wants to implement it. 31 | 32 | Implement Features 33 | ~~~~~~~~~~~~~~~~~~ 34 | 35 | Look through the GitHub issues for features. Anything tagged with "enhancement" 36 | and "help wanted" is open to whoever wants to implement it. 37 | 38 | Write Documentation 39 | ~~~~~~~~~~~~~~~~~~~ 40 | 41 | XMLStarlet CFFI could always use more documentation, whether as part of the 42 | official XMLStarlet CFFI docs, in docstrings, or even on the web in blog posts, 43 | articles, and such. 44 | 45 | Submit Feedback 46 | ~~~~~~~~~~~~~~~ 47 | 48 | The best way to send feedback is to file an issue at https://github.com/dimitern/xmlstarlet/issues. 49 | 50 | If you are proposing a feature: 51 | 52 | * Explain in detail how it would work. 53 | * Keep the scope as narrow as possible, to make it easier to implement. 54 | * Remember that this is a volunteer-driven project, and that contributions 55 | are welcome :) 56 | 57 | Get Started! 58 | ------------ 59 | 60 | Ready to contribute? Here's how to set up `xmlstarlet` for local development. 61 | 62 | 1. Fork the `xmlstarlet` repo on GitHub. 63 | 2. Clone your fork locally:: 64 | 65 | $ git clone git@github.com:your_name_here/xmlstarlet.git 66 | 67 | 3. Install your local copy into a virtualenv. Assuming you have Python 3 installed, 68 | this is how you set up your fork for local development:: 69 | 70 | $ cd xmlstarlet/ 71 | $ python3 -m venv .venv 72 | $ source .venv/bin/activate 73 | $ pip install -r requirements.txt 74 | 75 | The following one-liner command goes through all steps: cleans all 76 | build artifacts (if any), uninstalls the package (if installed), runs 77 | the linters (asserting scores haven't gone down and no new issues are 78 | found), the formatter (checking formatting won't change any of the files), 79 | builds a source distribution, then a binary wheel, running all tests, 80 | producing a coverage HTML report, and finally building the sphinx HTML, 81 | displayed in a browser on completion:: 82 | 83 | $ invoke clean --uninstall lint format --check dist --wheel test coverage docs --browser 84 | 85 | 4. Create a branch for local development:: 86 | 87 | $ git checkout -b name-of-your-bugfix-or-feature 88 | 89 | Now you can make your changes locally. 90 | 91 | 5. When you're done making changes, check that your changes pass flake8 and the 92 | tests, including testing other Python versions with tox:: 93 | 94 | $ invoke format lint test # optional; tox runs those as well 95 | $ tox 96 | 97 | Both `invoke` and `tox` are already installed from `requirements.txt`. 98 | To re-create all the `tox` environments and run all matrix combinations:: 99 | 100 | $ tox -r -e ALL # equivalent to `invoke clean-tests --tox` 101 | 102 | 6. Commit your changes and push your branch to GitHub:: 103 | 104 | $ git add . 105 | $ git commit -m "Your detailed description of your changes." 106 | $ git push -u origin name-of-your-bugfix-or-feature 107 | 108 | 7. Submit a pull request through the GitHub website. 109 | 110 | Pull Request Guidelines 111 | ----------------------- 112 | 113 | Before you submit a pull request, check that it meets these guidelines: 114 | 115 | 1. The pull request should include tests. 116 | 2. If the pull request adds functionality, the docs should be updated. Put 117 | your new functionality into a function with a docstring, and add the 118 | feature to the list in README.rst. 119 | 3. The pull request should work for Python 3.6 and later (currently, up to 3.10). 120 | Check https://github.com/dimitern/xmlstarlet/pulls and make sure all checks 121 | pass OK. Binary wheels are built automatically for each PR, or `git push` to 122 | a branch. 123 | 124 | Tips 125 | ---- 126 | 127 | To run a subset of tests:: 128 | 129 | $ pytest tests.test_xmlstarlet 130 | 131 | (`python setup.py test` will also work as alias of `pytest`). 132 | 133 | Deploying 134 | --------- 135 | 136 | A reminder for the maintainers on how to deploy. 137 | 138 | Make sure all your changes are committed (including an entry in HISTORY.rst). 139 | Then run:: 140 | 141 | $ invoke release --dry-run 142 | 143 | This runs `tox`, and then displays how the new version will look like, 144 | without pushing anything. 145 | 146 | If it goes OK, make the actual release with:: 147 | 148 | $ invoke release 149 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | History 3 | ======= 4 | 5 | 1.6.9 (unreleased) 6 | ------------------ 7 | 8 | * Now using latest `cibuildwheel` 2.8.1, which supports more architectures and builds, including 9 | PyPy 3.7 - 3.10 (on Linux x86 and x64, and MacOS x64). 10 | * Updated versions in `requirements.txt`. 11 | * Fixed security warnings (e.g. CVE-611) around xml2 and xslt libraries, pinning their versions to 12 | at least libxml2 2.9.1 and libxslt 1.1.28. 13 | 14 | 1.6.8 (2022-04-30) 15 | ------------------ 16 | 17 | * Added Python 3.10 support. 18 | * Fixed issue #199 (pending confirmation) - upgraded libxml2 and libxslt versions to fix CVEs 19 | * Upgraded development and build-time dependencies. 20 | * Now using latest `cibuildwheel` 2.5.0, which supports more architectures and builds. 21 | * Started to improve the documentation - added better usage examples. 22 | * Formatting and linting fixes 23 | 24 | 1.6.7 (2020-12-24) 25 | ------------------ 26 | 27 | * Fixed MacOS binary wheel builds 28 | 29 | 1.6.6 (2020-10-04) 30 | ------------------ 31 | 32 | * Simplified and automated building source and binary wheels for Linux, MacOS, and Windows via GitHub actions + `cibuildwheel`. 33 | * Improved documentation and local development workflow. 34 | * Fixes issue #51 (previously closed as "hard to fix", but now reopened). 35 | * Completely rewritten native Windows build process, based on libxslt. 36 | * Windows port does not support `ls` (and conversely `listdir()`). 37 | 38 | 1.6.5 (2020-09-29) 39 | ------------------ 40 | 41 | * No changes from previous release except up-to-date dependencies and some build fixes. 42 | * Fixes issue #118 (awaiting confirmation). 43 | 44 | 1.6.3 (2019-10-29) 45 | ------------------ 46 | 47 | * First working release on PyPI, based on xmlstarlet-1.6.1 source tarball. 48 | 49 | 1.6.2 (2019-10-28) 50 | ------------------ 51 | 52 | * Second (failed) release on PyPI, based on XMLStarlet master branch. 53 | 54 | 1.6.1 (2019-10-23) 55 | ------------------ 56 | 57 | * First (incomplete) release on PyPI, based on XMLStarlet master branch. 58 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019, Mikhail Grushinskiy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS.rst 2 | include CONTRIBUTING.rst 3 | include HISTORY.rst 4 | include LICENSE 5 | include README.rst 6 | 7 | include xmlstarlet_build.py 8 | 9 | recursive-include tests * 10 | recursive-exclude * __pycache__ 11 | recursive-exclude * *.py[co] 12 | 13 | recursive-include docs *.rst conf.py *.jpg *.png *.gif 14 | 15 | recursive-exclude * *.o *~ *.obj .?*/** *.pyc *.cache __pycache__ 16 | 17 | recursive-include xmlstarlet * *.Po 18 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | =============== 2 | XMLStarlet CFFI 3 | =============== 4 | 5 | 6 | .. image:: https://img.shields.io/pypi/v/xmlstarlet.svg 7 | :target: https://pypi.python.org/pypi/xmlstarlet 8 | 9 | .. image:: https://github.com/dimitern/xmlstarlet/workflows/cibuildwheel/badge.svg?branch=master&event=push 10 | :target: https://github.com/dimitern/xmlstarlet/actions?query=event%3Apush+branch%3Amaster+workflow%3Acibuildwheel 11 | :alt: cibuildwheel 12 | 13 | .. image:: https://readthedocs.org/projects/xmlstarlet/badge/?version=latest 14 | :target: https://xmlstarlet.readthedocs.io/en/latest/?badge=latest 15 | :alt: Documentation Status 16 | 17 | 18 | XMLStarlet Toolkit: Python CFFI bindings 19 | 20 | 21 | * Free software: MIT license 22 | * Documentation (this package): https://xmlstarlet.readthedocs.io. 23 | * Original XMLStarlet Documentation: http://xmlstar.sourceforge.net/doc/UG/ 24 | 25 | Features 26 | -------- 27 | 28 | Supports all XMLStarlet commands from Python, just `import xmlstarlet`: 29 | 30 | * `edit(*args)`: Edit/Update XML document(s) 31 | * `select(*args)`: Select data or query XML document(s) (XPATH, etc) 32 | * `transform(*args)`: Transform XML document(s) using XSLT 33 | * `validate(*args)`: Validate XML document(s) (well-formed/DTD/XSD/RelaxNG) 34 | * `format(*args)`: Format XML document(s) 35 | * `elements(*args)`: Display element structure of XML document 36 | * `canonicalize(*args)`: XML canonicalization 37 | * `listdir(*args)`: List directory as XML (**NOT** supported on Windows) 38 | * `escape(*args)`: Escape special XML characters 39 | * `unescape(*args)`: Unescape special XML characters 40 | * `pyx(*args)`: Convert XML into PYX format (based on ESIS - ISO 8879) 41 | * `depyx(*args)`: Convert PYX into XML 42 | 43 | For some examples, have a look at `tests/test_xmlstarlet.py`. 44 | 45 | Credits 46 | ------- 47 | 48 | Kudos to XMLStarlet and its maintainers and users (original sources on SourceForge_)! 49 | 50 | This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. 51 | 52 | Binary wheels built via GitHub Actions by cibuildwheel_ 53 | 54 | .. _SourceForge: https://sourceforge.net/projects/xmlstar/ 55 | .. _Cookiecutter: https://github.com/audreyr/cookiecutter 56 | .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage 57 | .. _cibuildwheel: https://github.com/joerick/cibuildwheel 58 | 59 | -------------------------------------------------------------------------------- /docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # xmlstarlet_cffi documentation build configuration file, created by 5 | # sphinx-quickstart on Fri Jun 9 13:47:02 2017. 6 | # 7 | # This file is execfile()d with the current directory set to its 8 | # containing dir. 9 | # 10 | # Note that not all possible configuration values are present in this 11 | # autogenerated file. 12 | # 13 | # All configuration values have a default; values that are commented out 14 | # serve to show the default. 15 | 16 | # If extensions (or modules to document with autodoc) are in another 17 | # directory, add these directories to sys.path here. If the directory is 18 | # relative to the documentation root, use os.path.abspath to make it 19 | # absolute, like shown here. 20 | # 21 | import os 22 | import sys 23 | 24 | sys.path.insert(0, os.path.abspath("..")) 25 | 26 | # -- General configuration --------------------------------------------- 27 | 28 | # If your documentation needs a minimal Sphinx version, state it here. 29 | # 30 | # needs_sphinx = '1.0' 31 | 32 | # Add any Sphinx extension module names here, as strings. They can be 33 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 34 | extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.napoleon"] 35 | 36 | # Add any paths that contain templates here, relative to this directory. 37 | templates_path = ["_templates"] 38 | 39 | # The suffix(es) of source filenames. 40 | # You can specify multiple suffix as a list of string: 41 | # 42 | # source_suffix = ['.rst', '.md'] 43 | source_suffix = ".rst" 44 | 45 | # The master toctree document. 46 | master_doc = "index" 47 | 48 | # General information about the project. 49 | project = "XMLStarlet CFFI" 50 | copyright = "2019, Mikhail Grushinskiy" 51 | author = "Mikhail Grushinskiy" 52 | 53 | # The version info for the project you're documenting, acts as replacement 54 | # for |version| and |release|, also used in various other places throughout 55 | # the built documents. 56 | # 57 | # The short X.Y version. 58 | version = "1.6.8" 59 | # The full version, including alpha/beta/rc tags. 60 | release = version 61 | 62 | # The language for content autogenerated by Sphinx. Refer to documentation 63 | # for a list of supported languages. 64 | # 65 | # This is also used if you do content translation via gettext catalogs. 66 | # Usually you set "language" from the command line for these cases. 67 | language = None 68 | 69 | # List of patterns, relative to source directory, that match files and 70 | # directories to ignore when looking for source files. 71 | # This patterns also effect to html_static_path and html_extra_path 72 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] 73 | 74 | # The name of the Pygments (syntax highlighting) style to use. 75 | pygments_style = "sphinx" 76 | 77 | # If true, `todo` and `todoList` produce output, else they produce nothing. 78 | todo_include_todos = False 79 | 80 | 81 | # -- Options for HTML output ------------------------------------------- 82 | 83 | # The theme to use for HTML and HTML Help pages. See the documentation for 84 | # a list of builtin themes. 85 | # 86 | html_theme = "alabaster" 87 | 88 | # Theme options are theme-specific and customize the look and feel of a 89 | # theme further. For a list of options available for each theme, see the 90 | # documentation. 91 | # 92 | html_theme_options = { 93 | "github_user": "dimitern", 94 | "github_repo": "xmlstarlet", 95 | "github_banner": "true", 96 | "github_button": "true", 97 | "page_width": "60%", 98 | "body_max_width": "none", 99 | } 100 | 101 | # Add any paths that contain custom static files (such as style sheets) here, 102 | # relative to this directory. They are copied after the builtin static files, 103 | # so a file named "default.css" will overwrite the builtin "default.css". 104 | html_static_path = ["_static"] 105 | 106 | 107 | # -- Options for HTMLHelp output --------------------------------------- 108 | 109 | # Output file base name for HTML help builder. 110 | htmlhelp_basename = "xmlstarlet_doc" 111 | 112 | 113 | # -- Options for LaTeX output ------------------------------------------ 114 | 115 | latex_elements = { 116 | # The paper size ('letterpaper' or 'a4paper'). 117 | # 118 | # 'papersize': 'letterpaper', 119 | # The font size ('10pt', '11pt' or '12pt'). 120 | # 121 | # 'pointsize': '10pt', 122 | # Additional stuff for the LaTeX preamble. 123 | # 124 | # 'preamble': '', 125 | # Latex figure (float) alignment 126 | # 127 | # 'figure_align': 'htbp', 128 | } 129 | 130 | # Grouping the document tree into LaTeX files. List of tuples 131 | # (source start file, target name, title, author, documentclass 132 | # [howto, manual, or own class]). 133 | latex_documents = [ 134 | ( 135 | master_doc, 136 | "xmlstarlet.tex", 137 | "XMLStarlet CFFI Documentation", 138 | "Mikhail Grushinskiy", 139 | "manual", 140 | ) 141 | ] 142 | 143 | 144 | # -- Options for manual page output ------------------------------------ 145 | 146 | # One entry per manual page. List of tuples 147 | # (source start file, name, description, authors, manual section). 148 | man_pages = [(master_doc, "xmlstarlet", "XMLStarlet CFFI Documentation", [author], 1)] 149 | 150 | 151 | # -- Options for Texinfo output ---------------------------------------- 152 | 153 | # Grouping the document tree into Texinfo files. List of tuples 154 | # (source start file, target name, title, author, 155 | # dir menu entry, description, category) 156 | texinfo_documents = [ 157 | ( 158 | master_doc, 159 | "xmlstarlet", 160 | "XMLStarlet CFFI Documentation", 161 | author, 162 | "xmlstarlet", 163 | "XMLStarlet Toolkit: Python CFFI Bindings.", 164 | "Miscellaneous", 165 | ) 166 | ] 167 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to XMLStarlet CFFI's documentation! 2 | =========================================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :caption: Contents: 7 | 8 | readme 9 | installation 10 | usage 11 | contributing 12 | authors 13 | history 14 | 15 | Indices and tables 16 | ================== 17 | * :ref:`genindex` 18 | * :ref:`modindex` 19 | * :ref:`search` 20 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Installation 5 | ============ 6 | 7 | 8 | Stable release 9 | -------------- 10 | 11 | To install XMLStarlet CFFI, run this command in your terminal: 12 | 13 | .. code-block:: console 14 | 15 | $ pip install xmlstarlet 16 | 17 | This is the preferred method to install XMLStarlet CFFI, as it will always install the most recent 18 | stable release from https://pypi.org. 19 | 20 | Binary wheels are automatically built and published for all major OS platforms 21 | (Linux, MacOS, and Windows), as well as source packages on every tagged release. 22 | 23 | Supported and tested on (64-bit) Python versions from 3.6+. 24 | 25 | 26 | If you don't have `pip`_ installed, this `Python installation guide`_ can guide 27 | you through the process. 28 | 29 | .. _pip: https://pip.pypa.io 30 | .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ 31 | 32 | 33 | From sources 34 | ------------ 35 | 36 | The sources for XMLStarlet CFFI can be downloaded from the `Github repo`_. 37 | 38 | You can either clone the public repository: 39 | 40 | .. code-block:: console 41 | 42 | $ git clone git://github.com/dimitern/xmlstarlet 43 | 44 | Or download the `tarball`_: 45 | 46 | .. code-block:: console 47 | 48 | $ curl -OL https://github.com/dimitern/xmlstarlet/tarball/master 49 | 50 | Once you have a copy of the source, you can install it with: 51 | 52 | .. code-block:: console 53 | 54 | $ python setup.py install 55 | 56 | Ideally, you would do this inside a `virtualenv`. 57 | 58 | .. _Github repo: https://github.com/dimitern/xmlstarlet 59 | .. _tarball: https://github.com/dimitern/xmlstarlet/tarball/master 60 | -------------------------------------------------------------------------------- /docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /docs/usage.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | Usage 3 | ===== 4 | 5 | Let's see some usage examples and description of each command. 6 | 7 | ------------ 8 | xml CLI Help 9 | ------------ 10 | 11 | .. highlight:: none 12 | 13 | The original ``xml`` CLI command has the following help description:: 14 | 15 | XMLStarlet Toolkit: Command line utilities for XML 16 | Usage: ./xml [] [] 17 | where is one of: 18 | ed (or edit) - Edit/Update XML document(s) 19 | sel (or select) - Select data or query XML document(s) (XPATH, etc) 20 | tr (or transform) - Transform XML document(s) using XSLT 21 | val (or validate) - Validate XML document(s) (well-formed/DTD/XSD/RelaxNG) 22 | fo (or format) - Format XML document(s) 23 | el (or elements) - Display element structure of XML document 24 | c14n (or canonic) - XML canonicalization 25 | ls (or list) - List directory as XML 26 | esc (or escape) - Escape special XML characters 27 | unesc (or unescape) - Unescape special XML characters 28 | pyx (or xmln) - Convert XML into PYX format (based on ESIS - ISO 8879) 29 | p2x (or depyx) - Convert PYX into XML 30 | are: 31 | -q or --quiet - no error output 32 | --doc-namespace - extract namespace bindings from input doc (default) 33 | --no-doc-namespace - don't extract namespace bindings from input doc 34 | --version - show version 35 | --help - show help 36 | Wherever file name mentioned in command help it is assumed 37 | that URL can be used instead as well. 38 | 39 | Type: .xml --help for command help 40 | 41 | XMLStarlet is a command line toolkit to query/edit/check/transform 42 | XML documents (for more information see http://xmlstar.sourceforge.net/) 43 | 44 | ^^^^^^^^^^^ 45 | From Python 46 | ^^^^^^^^^^^ 47 | 48 | .. highlight:: python 49 | 50 | To use XMLStarlet CFFI in a project:: 51 | 52 | import xmlstarlet 53 | 54 | Each command takes the same string arguments as the C version of ``xmlstarlet``, and returns an 55 | integer exit code (0 means success). 56 | 57 | Some examples for supported commands can be seen below. 58 | 59 | ----------------- 60 | xmlstarlet.edit() 61 | ----------------- 62 | 63 | .. highlight:: none 64 | 65 | Original ``xml`` CLI help text for ``edit``:: 66 | 67 | XMLStarlet Toolkit: Edit XML document(s) 68 | Usage: ./xml ed {} [ ... ] 69 | where 70 | - global options for editing 71 | - input XML document file name/uri (stdin otherwise) 72 | 73 | are: 74 | -P, or -S - preserve whitespace nodes. 75 | (or --pf, --ps) Note that space between attributes is not preserved 76 | -O (or --omit-decl) - omit XML declaration () 77 | -L (or --inplace) - edit file inplace 78 | -N = - predefine namespaces (name without 'xmlns:') 79 | ex: xsql=urn:oracle-xsql 80 | Multiple -N options are allowed. 81 | -N options must be last global options. 82 | --net - allow network access 83 | --help or -h - display help 84 | 85 | where 86 | -d or --delete 87 | --var 88 | -i or --insert -t (--type) elem|text|attr -n [-v (--value) ] 89 | -a or --append -t (--type) elem|text|attr -n [-v (--value) ] 90 | -s or --subnode -t (--type) elem|text|attr -n [-v (--value) ] 91 | -m or --move 92 | -r or --rename -v 93 | -u or --update -v (--value) 94 | -x (--expr) 95 | 96 | XMLStarlet is a command line toolkit to query/edit/check/transform 97 | XML documents (for more information see http://xmlstar.sourceforge.net/) 98 | 99 | .. highlight:: xml 100 | 101 | Let's assume you have this ``test.xml`` file you want to modify:: 102 | 103 | 104 | 105 | 106 | 107 | Link 108 | 109 | 110 | 111 | 112 | 113 | The modification is to find the first hyperlink, extract its text content, and add it as the 114 | value of a new attribute ``text=`` on the root (``html``) element, like so:: 115 | 116 | 117 | 118 | 119 | 120 | 121 | Link 122 | 123 | 124 | 125 | 126 | 127 | 128 | .. highlight:: python 129 | 130 | Here's how you can use the `edit` command to achieve this:: 131 | 132 | result = xmlstarlet.edit( 133 | "-S", 134 | "-N", "_=urn:local:html", 135 | "--var", "foo", "translate(//_:a[1]/text(), ' \n', '')", 136 | "-s", "/_:html", "-t", "attr", "-n", "text", "-v", "X", 137 | "-u", "$prev", "-x", "$foo", 138 | "./test.xml", 139 | "./test2.xml", 140 | ) 141 | if result != 0: 142 | print("Cannot update the XML") 143 | 144 | This demonstrates a number of options and techniques: 145 | 146 | ``-S`` 147 | preserve whitespaces in the input (do not trim). 148 | 149 | ``-N _=urn:local:html`` 150 | define namespaces present in the input (usable in expressions), here we define ``_`` as 151 | the namespace prefix for ``urn:local:html``. 152 | 153 | ``--var foo translate(//_:a[1]/text(), ' \n', '')`` 154 | assign the result of an XPath expression (in this case, a function call removing spaces 155 | and new-lines from the text content of the first ``a`` element), to a named variable ``foo``. 156 | 157 | ``-s /_:html -t attr -n text -v X`` 158 | create a subnode (in this case, attribute), named ``text``, with value ``X`` (temporarily), 159 | as a child of the root ``h:html`` element. 160 | 161 | ``-u $prev -x $foo`` 162 | update the node at the given XPath with the result of another XPath expression. In this case, 163 | the special variable ``$prev`` contains the last matched XPath (``/_:html``), and the variable 164 | ``$foo`` contains ``"Link"``. 165 | 166 | ``./test.xml`` 167 | the input XML file to operate on. 168 | 169 | ``./test2.xml`` 170 | the output XML file (will be **overwritten**). 171 | 172 | .. tip:: More examples can be found in the original ``xmlstarlet`` edit_ documentation. 173 | 174 | .. _edit: http://xmlstar.sourceforge.net/doc/UG/ch04s03.html 175 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | cffi==1.15.1 2 | invoke==1.7.3 3 | pycparser==2.21 4 | -------------------------------------------------------------------------------- /requirements_dev.txt: -------------------------------------------------------------------------------- 1 | black 2 | bumpversion 3 | coverage 4 | docutils>=0.14,<0.20 5 | flake8<7.0 6 | isort 7 | pylint 8 | pytest 9 | Sphinx<5.4 10 | sphinxcontrib-applehelp 11 | sphinxcontrib-devhelp 12 | sphinxcontrib-htmlhelp 13 | sphinxcontrib-jsmath 14 | sphinxcontrib-qthelp 15 | sphinxcontrib-serializinghtml 16 | tox 17 | twine 18 | auditwheel 19 | # Last supported version of markupsafe for 3.6. 20 | markupsafe==2.0.1 ; python_version < '3.7' 21 | markupsafe==2.1.1 ; python_version > '3.6' 22 | importlib-metadata>=4.4 23 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 1.6.8 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:docs/conf.py] 7 | search = version = "{current_version}" 8 | replace = version = "{new_version}" 9 | 10 | [bumpversion:file:setup.py] 11 | search = version="{current_version}" 12 | replace = version="{new_version}" 13 | 14 | [bumpversion:file:xmlstarlet/__init__.py] 15 | search = __version__ = "{current_version}" 16 | replace = __version__ = "{new_version}" 17 | 18 | [bdist_wheel] 19 | universal = 1 20 | 21 | [flake8] 22 | exclude = docs 23 | max-line-length = 120 24 | 25 | [pylint] 26 | max-line-length = 120 27 | extension-pkg-whitelist = xmlstarlet 28 | 29 | [isort] 30 | profile = black 31 | multi_line_output = 3 32 | line_length = 120 33 | 34 | [black] 35 | line_length = 120 36 | 37 | [aliases] 38 | test = pytest 39 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """The setup script.""" 5 | import sys 6 | 7 | from setuptools import find_packages, setup 8 | 9 | with open("README.rst", encoding="utf-8") as readme_file: 10 | readme = readme_file.read() 11 | 12 | with open("HISTORY.rst", encoding="utf-8") as history_file: 13 | history = history_file.read() 14 | 15 | requirements = ["cffi>=1.15.0"] 16 | 17 | setup_requirements = ["pytest-runner", "setuptools", "wheel>=0.37", "cffi>=1.15.0"] 18 | 19 | if sys.version_info[:2] in ((3, 7), (3, 6)): 20 | setup_requirements += ["pickle5"] 21 | 22 | test_requirements = ["pytest"] 23 | 24 | setup( 25 | author="Mikhail Grushinskiy", 26 | author_email="mgrouch@users.sourceforge.net", 27 | maintainer="Dimiter Naydenov", 28 | maintainer_email="dimitern@users.noreply.github.com", 29 | classifiers=[ 30 | "Development Status :: 6 - Mature", 31 | "Intended Audience :: Developers", 32 | "License :: OSI Approved :: MIT License", 33 | "Natural Language :: English", 34 | "Programming Language :: Python :: 3", 35 | "Programming Language :: Python :: 3.6", 36 | "Programming Language :: Python :: 3.7", 37 | "Programming Language :: Python :: 3.8", 38 | "Programming Language :: Python :: 3.9", 39 | "Programming Language :: Python :: 3.10", 40 | ], 41 | description="XMLStarlet Toolkit: Python CFFI bindings", 42 | install_requires=requirements, 43 | license="MIT license", 44 | long_description=readme + "\n\n" + history, 45 | long_description_content_type="text/x-rst", 46 | include_package_data=False, 47 | keywords="xmlstarlet cffi", 48 | name="xmlstarlet", 49 | packages=find_packages(include=["xmlstarlet"]), 50 | setup_requires=setup_requirements, 51 | cffi_modules=["xmlstarlet_build.py:FFIBUILDER"], 52 | python_requires=">=3.6.*", 53 | test_suite="tests", 54 | tests_require=test_requirements, 55 | url="https://github.com/dimitern/xmlstarlet", 56 | version="1.6.8", 57 | zip_safe=False, 58 | ) 59 | -------------------------------------------------------------------------------- /tasks.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tasks for maintaining the project. 3 | 4 | Execute 'invoke --list' for guidance on using Invoke 5 | """ 6 | # pylint: disable=invalid-name 7 | 8 | import platform 9 | import shutil 10 | import webbrowser 11 | 12 | from invoke import task 13 | 14 | try: 15 | from pathlib import Path 16 | 17 | Path().expanduser() 18 | except (ImportError, AttributeError): 19 | from pathlib2 import Path 20 | 21 | 22 | ROOT_DIR = Path(__file__).parent 23 | SETUP_FILE = ROOT_DIR.joinpath("setup.py") 24 | TEST_DIR = ROOT_DIR.joinpath("tests") 25 | SOURCE_DIR = ROOT_DIR.joinpath("xmlstarlet") 26 | TOX_DIR = ROOT_DIR.joinpath(".tox") 27 | COVERAGE_FILE = ROOT_DIR.joinpath(".coverage") 28 | COVERAGE_DIR = ROOT_DIR.joinpath("htmlcov") 29 | COVERAGE_REPORT = COVERAGE_DIR.joinpath("index.html") 30 | DOCS_DIR = ROOT_DIR.joinpath("docs") 31 | DOCS_BUILD_DIR = DOCS_DIR.joinpath("_build") 32 | DOCS_INDEX = DOCS_BUILD_DIR.joinpath("index.html") 33 | PYTHON_DIRS = [str(d) for d in [SOURCE_DIR, TEST_DIR]] 34 | 35 | 36 | def _delete_file(file): 37 | try: 38 | file.unlink(missing_ok=True) 39 | except TypeError: 40 | # missing_ok argument added in 3.8 41 | try: 42 | file.unlink() 43 | except FileNotFoundError: 44 | pass 45 | 46 | 47 | @task( 48 | help={ 49 | "wheel": "Build a binary wheel in addition to source package", 50 | } 51 | ) 52 | def dist(c, wheel=False): 53 | """ 54 | Build source and (optionally) a binary wheel packages, optionally installing it. 55 | """ 56 | commands = "sdist" if not wheel else "sdist bdist_wheel" 57 | c.run(f"python {SETUP_FILE} {commands}") 58 | 59 | 60 | @task( 61 | name="format", 62 | pre=[dist], 63 | help={"check": "Checks if source is formatted without applying changes"}, 64 | ) 65 | def format_sources(c, check=False): 66 | """ 67 | Format code 68 | """ 69 | python_dirs_string = " ".join(PYTHON_DIRS) 70 | # Run black 71 | black_options = "--check" if check else "" 72 | c.run(f"black {black_options} . {python_dirs_string}") 73 | # Run isort 74 | isort_options = "--check-only" if check else "" 75 | c.run(f"isort {isort_options} {python_dirs_string}") 76 | 77 | 78 | @task(pre=[dist]) 79 | def lint(c): 80 | """ 81 | Lint code 82 | """ 83 | c.run("flake8 *.py") 84 | c.run("pylint --rcfile=setup.cfg *.py") 85 | 86 | 87 | @task(pre=[dist]) 88 | def test(c): 89 | """ 90 | Run tests 91 | """ 92 | pty = platform.system() == "Linux" 93 | c.run(f"python {SETUP_FILE} test", pty=pty) 94 | 95 | 96 | @task( 97 | help={ 98 | "publish": "Publish the result via coveralls (not working)", 99 | "browser": "Open the local HTML coverage report in the default browser", 100 | } 101 | ) 102 | def coverage(c, publish=False, browser=False): 103 | """ 104 | Create coverage report 105 | """ 106 | c.run(f"coverage run --source {SOURCE_DIR} -m pytest") 107 | c.run("coverage report") 108 | if publish: 109 | # Publish the results via coveralls 110 | c.run("coveralls") 111 | 112 | # Build a local report 113 | c.run("coverage html") 114 | if browser: 115 | webbrowser.open(COVERAGE_REPORT.as_uri()) 116 | 117 | 118 | @task(help={"browser": "Open the built documentation in the default browser"}) 119 | def docs(c, browser=False): 120 | """ 121 | Generate documentation 122 | """ 123 | c.run(f"sphinx-build -b html {DOCS_DIR} {DOCS_BUILD_DIR}") 124 | if browser: 125 | webbrowser.open(DOCS_INDEX.as_uri()) 126 | 127 | 128 | @task 129 | def clean_docs(c): 130 | """ 131 | Clean up files from documentation builds 132 | """ 133 | c.run(f"rm -fr {DOCS_BUILD_DIR}") 134 | 135 | 136 | @task 137 | def clean_build(c): 138 | """ 139 | Clean up files from package building 140 | """ 141 | c.run("rm -fr build/") 142 | c.run("rm -fr dist/") 143 | c.run("rm -fr xmlstarlet/config.h " "xmlstarlet/Makefile " "xmlstarlet/config.status") 144 | c.run("rm -fr .eggs/") 145 | c.run("find . -name '*.egg-info' -exec rm -fr {} +") 146 | c.run("find . -name '*.egg' -exec rm -f {} +") 147 | 148 | 149 | @task 150 | def clean_python(c): 151 | """ 152 | Clean up Python file artifacts 153 | """ 154 | c.run("find . -name '*.pyc' -exec rm -f {} +") 155 | c.run("find . -name '*.pyo' -exec rm -f {} +") 156 | c.run("find . -name '*~' -exec rm -f {} +") 157 | c.run("find . -name '__pycache__' -exec rm -fr {} +") 158 | 159 | 160 | @task(help={"tox": "Clean tox directory {!r} as well"}) 161 | def clean_tests(c, tox=False): # pylint: disable=unused-argument 162 | """ 163 | Clean up files from testing 164 | """ 165 | _delete_file(COVERAGE_FILE) 166 | if tox: 167 | shutil.rmtree(TOX_DIR, ignore_errors=True) 168 | shutil.rmtree(COVERAGE_DIR, ignore_errors=True) 169 | 170 | 171 | @task( 172 | pre=[clean_build, clean_python, clean_tests, clean_docs], 173 | help={"uninstall": "Also uninstall the package (if installed)"}, 174 | ) 175 | def clean(c, uninstall=False): 176 | """ 177 | Runs all clean sub-tasks 178 | """ 179 | if uninstall: 180 | c.run("pip uninstall -y xmlstarlet") 181 | 182 | 183 | @task( 184 | pre=[clean], 185 | help={"dry-run": "Only display what will change, do NOT commit/tag/push"}, 186 | ) 187 | def release(c, dry_run=False): 188 | """ 189 | Run all tox tests, and if successful, bump the patch 190 | version of the package, commit and tag it, then push 191 | to GitHub. If `dry_run` is True, no commit or push is 192 | done. Working directory must be clean (no uncommited 193 | changes). 194 | """ 195 | tox_args = "--skip-pkg-install -e py37" if not dry_run else "" 196 | c.run(f"tox {tox_args}") 197 | dry = "--dry-run" if dry_run else "" 198 | c.run(f"bump2version {dry} --verbose patch") 199 | 200 | if not dry_run: 201 | c.run("git push --tags") 202 | -------------------------------------------------------------------------------- /tests/test.rng: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Link 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/test.xslt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/test2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Link 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/test_xmlstarlet.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """Tests for `xmlstarlet` package.""" 4 | 5 | import os 6 | 7 | import pytest 8 | 9 | import xmlstarlet 10 | 11 | 12 | @pytest.fixture(scope="session", autouse=True) 13 | def testsdir(): 14 | original = os.getcwd() 15 | os.chdir(os.path.dirname(os.path.realpath(__file__))) 16 | yield 17 | os.chdir(original) 18 | 19 | 20 | def test_edit(): 21 | assert ( 22 | xmlstarlet.edit( 23 | "-S", 24 | "-N", 25 | "_=urn:local:html", 26 | "--var", 27 | "foo", 28 | "translate(//_:a[1]/text(), ' \n', '')", 29 | "-s", 30 | "/_:html", 31 | "-t", 32 | "attr", 33 | "-n", 34 | "text", 35 | "-v", 36 | "X", 37 | "-u", 38 | "$prev", 39 | "-x", 40 | "$foo", 41 | "./test.xml", 42 | "./test2.xml", 43 | ) 44 | == 0 45 | ) 46 | 47 | 48 | def test_element(): 49 | assert xmlstarlet.element("./test.xml") == 0 50 | 51 | 52 | def test_escape(): 53 | assert xmlstarlet.escape("./test.xml") == 0 54 | 55 | 56 | def test_unescape(): 57 | assert xmlstarlet.unescape("./test2.xml") == 0 58 | 59 | 60 | def test_canonicalize(): 61 | assert xmlstarlet.canonicalize("test.xml") == 0 62 | 63 | 64 | def test_pyx(): 65 | assert xmlstarlet.pyx("test.xml") == 0 66 | 67 | 68 | def test_depyx(): 69 | assert xmlstarlet.depyx("test.xml") == 0 70 | 71 | 72 | def test_select(): 73 | assert xmlstarlet.select("-t", "-f", "-n", "-b", "test.xml") == 0 74 | 75 | 76 | def test_format(): 77 | assert xmlstarlet.format("test2.xml") == 0 78 | 79 | 80 | def test_listdir(): 81 | # ls is not supported on Windows. 82 | expected = 0 83 | if os.name == "nt": 84 | expected = 1 85 | assert xmlstarlet.listdir() == expected 86 | 87 | 88 | def test_transform(): 89 | assert xmlstarlet.transform("test.xslt", "test.xml") == 0 90 | 91 | 92 | def test_validate(): 93 | assert xmlstarlet.validate("-r", "test.rng", "-e", "test.xml") == 0 94 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py{36,37,38,39,310}, lint, format, docs, resolver2020 3 | skip-missing-interpreters = true 4 | parallel-live = true 5 | 6 | [testenv:lint] 7 | basepython = python 8 | commands = invoke lint 9 | 10 | [testenv:format] 11 | basepython = python 12 | commands_pre = pip --disable-pip-version-check install --pre -r requirements.txt 13 | commands = 14 | invoke dist 15 | invoke format --check 16 | 17 | [testenv:docs] 18 | basepython = python 19 | commands = invoke docs 20 | 21 | [testenv:resolver2020] 22 | basepython = python 23 | commands = 24 | pip --disable-pip-version-check install --force-reinstall --prefer-binary -f dist/ xmlstarlet --use-feature=2020-resolver 25 | 26 | [testenv:py310] 27 | commands_pre = 28 | pip install -U pip setuptools wheel 29 | pip --disable-pip-version-check install -r requirements.txt -r requirements_dev.txt 30 | pip install xmlstarlet --prefer-binary --no-deps --no-index -f dist/ 31 | 32 | [testenv] 33 | commands_pre = 34 | pip --disable-pip-version-check install -r requirements.txt -r requirements_dev.txt 35 | pip install xmlstarlet --prefer-binary --no-deps --no-index -f dist/ 36 | commands = 37 | invoke test coverage 38 | twine check dist/* 39 | -------------------------------------------------------------------------------- /xmlstarlet/AUTHORS: -------------------------------------------------------------------------------- 1 | Mikhail Grushinskiy 2 | -------------------------------------------------------------------------------- /xmlstarlet/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2004 Mikhail Grushinskiy. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /xmlstarlet/ChangeLog: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /xmlstarlet/Copyright: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2004 Mikhail Grushinskiy. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /xmlstarlet/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = Copyright examples solaris tests 2 | WIN32_DIST = README TODO Copyright COPYING AUTHORS ChangeLog INSTALL NEWS xml.exe 3 | WIN32_doc_DIST = $(generated_docs) doc/html.css 4 | 5 | ACLOCAL_AMFLAGS = -I m4 6 | if GCC 7 | AM_CFLAGS = -Wall -pedantic 8 | endif 9 | 10 | GIT_DESCRIBE = git describe --tags --dirty 11 | 12 | # TODO: figure out why log removal is needed and/or make it completely automatic 13 | dist-hook: 14 | @for log in $(srcdir)/examples/*.log ; do if [ -f "$$log" ] ; then \ 15 | rm $(srcdir)/examples/*.log ; \ 16 | echo 'ERROR: log files need to cleaned BEFORE making tarball, try again'; exit 1 ; fi ; done 17 | @ if [ -d .git ] ; then \ 18 | if [ $(VERSION) != `$(GIT_DESCRIBE)` ] ; then \ 19 | echo 'ERROR: version mismatch, rerun autoconf -f' ; exit 1 ; fi ; \ 20 | $(SED) 's/\[m4_esyscmd_s(\[$(GIT_DESCRIBE)\])\]/[$(VERSION)]/' \ 21 | $(srcdir)/configure.ac > $(distdir)/configure.ac ; fi 22 | 23 | cleantar: 24 | @(rm -f xmlstarlet*.tar.gz) 25 | 26 | rpm: cleantar distdir xmlstarlet.spec 27 | cp xmlstarlet.spec $(distdir) 28 | $(AMTAR) -czf $(distdir).tar.gz $(distdir) 29 | rpmbuild -ta $(distdir).tar.gz 30 | 31 | $(distdir)-win32.zip: $(WIN32_DIST) $(WIN32_doc_DIST) 32 | mkdir -p /tmp/$(distdir)/doc 33 | cp $^ /tmp/$(distdir) 34 | cd /tmp/$(distdir) && mv $(notdir $(WIN32_doc_DIST)) /tmp/$(distdir)/doc 35 | strip /tmp/$(distdir)/xml.exe 36 | cd /tmp && zip -9 --symlinks --recurse-paths --to-crlf --move \ 37 | $(distdir)-win32.zip $(distdir) 38 | mv /tmp/$(distdir)-win32.zip . 39 | 40 | dist-win32: $(distdir)-win32.zip 41 | 42 | version.h: VERSION 43 | @if [ -d .git ] ; then \ 44 | VERSION=`$(GIT_DESCRIBE)`; \ 45 | else VERSION=$(VERSION) ; fi; \ 46 | NEW_VERSION="#define VERSION \"$$VERSION\""; \ 47 | OLD_VERSION=`cat version.h 2>/dev/null` ; \ 48 | if [ "$$NEW_VERSION" != "$$OLD_VERSION" ] ; then \ 49 | echo "$$NEW_VERSION" > version.h ; \ 50 | echo "version.h: $$NEW_VERSION"; fi 51 | VERSION: 52 | 53 | # need to build version.h even if dependency files haven't been 54 | # generated 55 | src/xml.o : version.h 56 | 57 | 58 | 59 | # testing 60 | include examples/tests.mk 61 | 62 | # building executable 63 | bin_PROGRAMS = xml 64 | 65 | include src/sources.mk 66 | xml_SOURCES += version.h 67 | nodist_xml_SOURCES = $(generated_usage_sources) 68 | EXTRA_DIST += $(usage_texts) usage2c.awk 69 | 70 | .txt.c: 71 | $(AM_V_GEN)$(AWK) -f $(srcdir)/usage2c.awk $< > $@ 72 | $(generated_usage_sources) : usage2c.awk 73 | 74 | 75 | # doc 76 | include doc/doc.mk 77 | 78 | man_MANS = $(manpage) 79 | dist_doc_DATA = $(userguide_gen) doc/html.css $(txtguide) 80 | EXTRA_DIST += $(manpage_src) $(userguide_src) $(txtguide_src) 81 | EXTRA_DIST += $(buildfiles_docs) $(manpage) 82 | 83 | 84 | CLEANFILES = version.h $(generated_usage_sources) 85 | MAINTAINERCLEANFILES = $(manpage) $(userguide_gen) $(txtguide) 86 | 87 | .PHONY: cleantar rpm dist-win32 VERSION doc 88 | -------------------------------------------------------------------------------- /xmlstarlet/README: -------------------------------------------------------------------------------- 1 | 2 | XMLStarlet is a command line XML toolkit which can be used to transform, 3 | query, validate, and edit XML documents and files using simple set of shell 4 | commands in similar way it is done for plain text files using grep/sed/awk/ 5 | tr/diff/patch. 6 | 7 | -------------------------------------------------------------------------------- /xmlstarlet/TODO: -------------------------------------------------------------------------------- 1 | 1. xml ed option is highly incomplete 2 | 2. How about XUpdate? (see http://www.xmldb.org/) 3 | 3. just do grep TODO src/*.c and you'll figure it out 4 | 4. generate xsd/DTD (best guess) from given XML document 5 | -------------------------------------------------------------------------------- /xmlstarlet/doc/doc.mk: -------------------------------------------------------------------------------- 1 | userguide = doc/xmlstarlet-ug 2 | userguide_gen = $(userguide).html 3 | if HAVE_FOP 4 | userguide_gen += $(userguide).pdf 5 | if HAVE_PDF2PS 6 | userguide_gen += $(userguide).ps 7 | endif 8 | endif 9 | userguide_src = $(srcdir)/$(userguide).xml 10 | 11 | txtguide = doc/xmlstarlet.txt 12 | txtguide_src = $(srcdir)/doc/gen-doc 13 | 14 | manpage = doc/xmlstarlet.1 15 | manpage_src = $(srcdir)/doc/xmlstarlet-man.xml 16 | 17 | generated_docs = $(userguide_gen) $(txtguide) $(manpage) 18 | buildfiles_docs = $(srcdir)/doc/replace-PROG-VERSION.xsl $(srcdir)/doc/xmlstar-fodoc-style.xsl 19 | 20 | DOCBOOK_PARAMS = \ 21 | --param section.autolabel 1 \ 22 | --stringparam generate.toc 'book toc,title' 23 | 24 | EDIT_XML = $(XSLTPROC) \ 25 | --stringparam VERSION '$(VERSION)' \ 26 | --stringparam PROG "`echo xml | $(SED) '$(program_transform_name)'`" \ 27 | $(srcdir)/doc/replace-PROG-VERSION.xsl 28 | 29 | if BUILD_DOCS 30 | 31 | .xml.html: 32 | $(V_DOCBOOK)$(EDIT_XML) $< | $(XSLTPROC) $(DOCBOOK_PARAMS) \ 33 | --stringparam html.stylesheet html.css \ 34 | http://docbook.sourceforge.net/release/xsl-ns/current/html/docbook.xsl \ 35 | - > $@ 36 | 37 | .xml.fo: 38 | $(V_DOCBOOK)$(EDIT_XML) $< | $(XSLTPROC) $(DOCBOOK_PARAMS) $(srcdir)/doc/xmlstar-fodoc-style.xsl - > $@ 39 | 40 | if HAVE_FOP 41 | .fo.pdf: 42 | $(V_FOP)$(FOP) -q $< $@ 43 | endif 44 | if HAVE_PDF2PS 45 | .pdf.ps: 46 | $(AM_V_GEN)$(PDF2PS) $< $@ 47 | endif 48 | 49 | $(userguide).html : $(userguide_src) 50 | 51 | $(manpage): $(manpage_src) 52 | $(V_DOCBOOK)$(EDIT_XML) $< | $(XSLTPROC) -o $@ \ 53 | http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl \ 54 | - 55 | 56 | $(txtguide): $(txtguide_src) $(usage_texts) 57 | $(AM_V_GEN)srcdir=$(srcdir) SED=$(SED) transform='$(program_transform_name)' $< ./xml > $@ 58 | 59 | clean-doc: 60 | rm -f $(generated_docs) 61 | 62 | endif BUILD_DOCS 63 | 64 | # NOTE: if put inside "if BUILD_DOCS" automake issues a warning 65 | .PHONY: clean-doc 66 | -------------------------------------------------------------------------------- /xmlstarlet/doc/gen-doc: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | : "${SED=sed}" 4 | XMLSTARLET=$1 5 | STAR_NAME=`echo xml | ${SED} "$transform"` 6 | 7 | { 8 | echo "" 9 | echo "" 10 | echo " XMLSTARLET USER'S GUIDE" 11 | echo "" 12 | echo " see also http://xmlstar.sourceforge.net/" 13 | echo "" 14 | echo "" 15 | 16 | echo "" 17 | echo "" 18 | echo "1. BASIC COMMAND LINE OPTIONS" 19 | echo "====================================================" 20 | echo "" 21 | echo "$STAR_NAME --help" 22 | $SED '/^#/d' src/usage.txt 23 | 24 | echo "" 25 | echo "" 26 | echo "" 27 | echo "2. Select/Query XML documents" 28 | echo "====================================================" 29 | echo "" 30 | echo "$STAR_NAME sel --help" 31 | $SED '/^#/d' src/select-usage.txt 32 | 33 | echo "" 34 | echo "" 35 | echo "" 36 | echo "3. Editing XML documents" 37 | echo "====================================================" 38 | echo "" 39 | echo "$STAR_NAME ed --help" 40 | $SED '/^#/d' src/edit-usage.txt 41 | 42 | echo "" 43 | echo "" 44 | echo "" 45 | echo "4. Using XSLT to transform XML documents" 46 | echo "====================================================" 47 | echo "" 48 | echo "$STAR_NAME tr --help" 49 | $SED '/^#/d' src/trans-usage.txt 50 | 51 | echo "" 52 | echo "" 53 | echo "" 54 | echo "5. Formatting XML documents" 55 | echo "====================================================" 56 | echo "" 57 | echo "$STAR_NAME fo --help" 58 | $SED '/^#/d' src/format-usage.txt 59 | 60 | echo "" 61 | echo "" 62 | echo "" 63 | echo "6. Validating XML documents" 64 | echo "====================================================" 65 | echo "" 66 | echo "$STAR_NAME val --help" 67 | $SED '/^#/d' src/validate-usage.txt 68 | 69 | echo "" 70 | echo "" 71 | echo "" 72 | echo "7. Displaying structure of XML documents" 73 | echo "====================================================" 74 | echo "" 75 | echo "$STAR_NAME el --help" 76 | $SED '/^#/d' src/elem-usage.txt 77 | 78 | echo "" 79 | echo "" 80 | echo "" 81 | echo "" 82 | echo "8. Escape/Unescape special XML characters" 83 | echo "====================================================" 84 | echo "" 85 | echo "$STAR_NAME esc --help" 86 | $SED '/^#/d' src/escape-usage.txt 87 | 88 | echo "" 89 | echo "" 90 | echo "" 91 | echo "" 92 | echo "9. List directory as XML" 93 | echo "====================================================" 94 | echo "" 95 | echo "$STAR_NAME ls --help" 96 | $SED '/^#/d' src/ls-usage.txt 97 | 98 | echo "" 99 | echo "" 100 | echo "" 101 | echo "" 102 | echo "10. XML canonicalization" 103 | echo "====================================================" 104 | echo "" 105 | echo "$STAR_NAME c14n --help" 106 | $SED '/^#/d' src/c14n-usage.txt 107 | 108 | echo "" 109 | echo "" 110 | echo "" 111 | echo "" 112 | echo "11. Convert XML into PYX format (based on ESIS - ISO 8879)" 113 | echo "====================================================" 114 | echo "" 115 | echo "$STAR_NAME pyx --help" 116 | $SED '/^#/d' src/pyx-usage.txt 117 | 118 | echo "" 119 | echo "" 120 | echo "" 121 | echo "" 122 | echo "12. Examples:" 123 | echo "====================================================" 124 | echo "" 125 | echo "Input1" 126 | echo "examples/xml/table.xml" 127 | echo "" 128 | cat "$srcdir"/examples/xml/table.xml 129 | echo "" 130 | echo "" 131 | echo "Input2" 132 | echo "examples/xml/tab-obj.xml" 133 | echo "" 134 | cat "$srcdir"/examples/xml/tab-obj.xml 135 | echo "" 136 | echo "" 137 | echo "Input3" 138 | echo "examples/html/hello1.html" 139 | echo "" 140 | cat "$srcdir"/examples/html/hello1.html 141 | echo "" 142 | echo "" 143 | echo "Input4" 144 | echo "examples/sgml/docbook1.sgml" 145 | echo "" 146 | cat "$srcdir"/examples/sgml/docbook1.sgml 147 | echo "" 148 | echo "" 149 | echo "Stylesheet1" 150 | echo "examples/xsl/sum1.xsl" 151 | echo "" 152 | cat "$srcdir"/examples/xsl/sum1.xsl 153 | echo "" 154 | echo "" 155 | echo "Stylesheet2" 156 | echo "examples/xsl/hello1.xsl" 157 | echo "" 158 | cat "$srcdir"/examples/xsl/hello1.xsl 159 | echo "" 160 | echo "" 161 | echo "Stylesheet3" 162 | echo "examples/xsl/param1.xsl" 163 | echo "" 164 | cat "$srcdir"/examples/xsl/param1.xsl 165 | echo "" 166 | echo "" 167 | 168 | echo "" 169 | 170 | for eg in "$srcdir"/examples/*[0-9] 171 | do 172 | if [ -x "$eg" ] 173 | then 174 | echo "Command:" 175 | sed -e '/^#!/d' "$eg" 176 | echo "Result Output:" 177 | cat "$srcdir"/examples/results/`basename $eg`.out 178 | echo "" 179 | echo "" 180 | fi 181 | done 182 | 183 | echo "" 184 | } | $SED -e "s:\./xmlstarlet:$STAR_NAME:g; s:PROG:$STAR_NAME:g" 185 | 186 | 187 | -------------------------------------------------------------------------------- /xmlstarlet/doc/html.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #FFFFFF; 3 | } 4 | 5 | h1, h2, h3, h4, h5 { 6 | color: #800000; 7 | font-family: sans-serif; 8 | } 9 | 10 | span.term { 11 | font-weight: bold; 12 | } 13 | 14 | div.sidebar { 15 | background: #F0F0F0; 16 | border: 1px solid gray; 17 | padding: 5px; 18 | margin: 20px; 19 | } 20 | 21 | pre.programlisting { 22 | background: #F0F0F0; 23 | border: 1px solid gray; 24 | padding: 2px; 25 | font-size: 10pt; 26 | white-space: pre; 27 | } 28 | -------------------------------------------------------------------------------- /xmlstarlet/doc/replace-PROG-VERSION.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /xmlstarlet/doc/xmlstar-fodoc-style.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | bold 12 | normal 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /xmlstarlet/doc/xmlstarlet-man.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 2012 8 | 9 | 10 | 11 | Mikhail 12 | Grushinskiy 13 | 14 | XMLStarlet creator. 15 | 16 | 17 | Version 18 | 19 | 20 | 21 | xmlstarlet 22 | 1 23 | XMLStarlet Manual 24 | 25 | 26 | 27 | xmlstarlet 28 | 29 | command line XML/XSLT toolkit 30 | 31 | 32 | 33 | 34 | 35 | options 36 | command 37 | cmd-options 38 | 39 | 40 | 41 | 42 | Introduction 43 | 44 | XMLStarlet is a set of command line utilities (tools) which can be 45 | used to transform, query, validate, and edit XML documents and files using 46 | simple set of shell commands in similar way it is done for plain text 47 | files using UNIX grep, sed, awk, diff, patch, join, etc commands. This set 48 | of command line utilities can be used by those who deal with many XML 49 | documents on UNIX shell command prompt as well as for automated XML 50 | processing with shell scripts. 51 | 52 | 53 | 54 | Options 55 | 56 | 57 | 58 | 59 | 60 | 61 | Display the version of 62 | xmlstarlet. 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | Display help. 71 | 72 | 73 | 74 | 75 | 76 | 77 | Commands 78 | 79 | 80 | command 81 | for command specific help 82 | 83 | Available commands include: 84 | 85 | 86 | 87 | 88 | 89 | 90 | Edit/update XML document(s). 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | Select data or query XML document(s) (XPATH, 99 | etc). 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | Transform XML documents(s) using XSLT. 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | Validate XML document(s) 116 | (well-formed/DTD/XSD/RelaxNG). 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | Format XML document(s). 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | Display element structure of XML document. 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | XML canonicalization. 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | List directory as XML. 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | Escape special XML characters. 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | Unescape special XML characters. 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | Convert XML into PYX format (based on ESIS - ISO 173 | 8879). 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | Convert PYX into XML. 182 | 183 | 184 | 185 | 186 | 187 | 188 | References 189 | 190 | XMLStarlet is a command line toolkit to query/edit/check/transform 191 | XML documents (for more information see 192 | http://xmlstar.sourceforge.net/). 193 | 194 | 195 | 196 | Bugs 197 | Report bugs to the mailing list, 198 | xmlstar-devel@lists.sourceforge.net or the bug tracker: . 200 | 201 | 202 | 203 | -------------------------------------------------------------------------------- /xmlstarlet/doc/xmlstarlet-ug.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimitern/xmlstarlet/40147930485bc910130268923ecf9500a3879046/xmlstarlet/doc/xmlstarlet-ug.html -------------------------------------------------------------------------------- /xmlstarlet/doc/xmlstarlet-ug.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimitern/xmlstarlet/40147930485bc910130268923ecf9500a3879046/xmlstarlet/doc/xmlstarlet-ug.pdf -------------------------------------------------------------------------------- /xmlstarlet/doc/xmlstarlet.1: -------------------------------------------------------------------------------- 1 | '\" t 2 | .\" Title: xmlstarlet 3 | .\" Author: Mikhail Grushinskiy 4 | .\" Generator: DocBook XSL-NS Stylesheets v1.76.1 5 | .\" Date: 08/26/2012 6 | .\" Manual: XMLStarlet Manual 7 | .\" Source: Version 1.4.0 8 | .\" Language: English 9 | .\" 10 | .TH "XMLSTARLET" "1" "08/26/2012" "Version 1.4.0" "XMLStarlet Manual" 11 | .\" ----------------------------------------------------------------- 12 | .\" * Define some portability stuff 13 | .\" ----------------------------------------------------------------- 14 | .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 15 | .\" http://bugs.debian.org/507673 16 | .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html 17 | .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 18 | .ie \n(.g .ds Aq \(aq 19 | .el .ds Aq ' 20 | .\" ----------------------------------------------------------------- 21 | .\" * set default formatting 22 | .\" ----------------------------------------------------------------- 23 | .\" disable hyphenation 24 | .nh 25 | .\" disable justification (adjust text to left margin only) 26 | .ad l 27 | .\" ----------------------------------------------------------------- 28 | .\" * MAIN CONTENT STARTS HERE * 29 | .\" ----------------------------------------------------------------- 30 | .SH "NAME" 31 | xmlstarlet \- command line XML/XSLT toolkit 32 | .SH "SYNOPSIS" 33 | .HP \w'\fBxml\fR\ 'u 34 | \fBxml\fR [\fIoptions\fR...] {\fIcommand\fR} [\fIcmd\-options\fR...] 35 | .SH "INTRODUCTION" 36 | .PP 37 | XMLStarlet is a set of command line utilities (tools) which can be used to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc commands\&. This set of command line utilities can be used by those who deal with many XML documents on UNIX shell command prompt as well as for automated XML processing with shell scripts\&. 38 | .SH "OPTIONS" 39 | .PP 40 | \fB\-\-version\fR 41 | .RS 4 42 | Display the version of 43 | xmlstarlet\&. 44 | .RE 45 | .PP 46 | \fB\-\-help\fR 47 | .RS 4 48 | Display help\&. 49 | .RE 50 | .SH "COMMANDS" 51 | .PP 52 | \fBxml\fR 53 | \fIcommand\fR 54 | \fB\-\-help\fR 55 | for command specific help 56 | .PP 57 | Available commands include: 58 | .PP 59 | \fBed (or edit)\fR 60 | .RS 4 61 | Edit/update XML document(s)\&. 62 | .RE 63 | .PP 64 | \fBsel (or select)\fR 65 | .RS 4 66 | Select data or query XML document(s) (XPATH, etc)\&. 67 | .RE 68 | .PP 69 | \fBtr (or transform)\fR 70 | .RS 4 71 | Transform XML documents(s) using XSLT\&. 72 | .RE 73 | .PP 74 | \fBval (or validate)\fR 75 | .RS 4 76 | Validate XML document(s) (well\-formed/DTD/XSD/RelaxNG)\&. 77 | .RE 78 | .PP 79 | \fBfo (or format)\fR 80 | .RS 4 81 | Format XML document(s)\&. 82 | .RE 83 | .PP 84 | \fBel (or elements)\fR 85 | .RS 4 86 | Display element structure of XML document\&. 87 | .RE 88 | .PP 89 | \fBc14n (or canonic)\fR 90 | .RS 4 91 | XML canonicalization\&. 92 | .RE 93 | .PP 94 | \fBls (or list)\fR 95 | .RS 4 96 | List directory as XML\&. 97 | .RE 98 | .PP 99 | \fBesc (or escape)\fR 100 | .RS 4 101 | Escape special XML characters\&. 102 | .RE 103 | .PP 104 | \fBunesc (or unescape)\fR 105 | .RS 4 106 | Unescape special XML characters\&. 107 | .RE 108 | .PP 109 | \fBpyx (or xmln)\fR 110 | .RS 4 111 | Convert XML into PYX format (based on ESIS \- ISO 8879)\&. 112 | .RE 113 | .PP 114 | \fBp2x (or depyx)\fR 115 | .RS 4 116 | Convert PYX into XML\&. 117 | .RE 118 | .SH "REFERENCES" 119 | .PP 120 | XMLStarlet is a command line toolkit to query/edit/check/transform XML documents (for more information see http://xmlstar\&.sourceforge\&.net/)\&. 121 | .SH "BUGS" 122 | .PP 123 | Report bugs to the mailing list, 124 | xmlstar\-devel@lists\&.sourceforge\&.net 125 | or the bug tracker: 126 | \m[blue]\fB\%http://sourceforge.net/tracker/?group_id=66612&atid=515106\fR\m[]\&. 127 | .SH "AUTHOR" 128 | .PP 129 | \fBMikhail Grushinskiy\fR 130 | .RS 4 131 | XMLStarlet creator\&. 132 | .RE 133 | .SH "COPYRIGHT" 134 | .br 135 | Copyright \(co 2012 136 | .br 137 | -------------------------------------------------------------------------------- /xmlstarlet/doc/xmlstarlet.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimitern/xmlstarlet/40147930485bc910130268923ecf9500a3879046/xmlstarlet/doc/xmlstarlet.txt -------------------------------------------------------------------------------- /xmlstarlet/examples/N-order: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # make sure -N after other option is allowed 3 | ./xmlstarlet sel -T -N n=n -t -v /n:x xml/foo.xml 2>&1 >/dev/null 4 | ./xmlstarlet ed -P -N n=n -d /n:x xml/foo.xml 2>&1 >/dev/null 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/bigxml: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # check error messages on lines past 2^16 3 | 4 | SEDLINUM_PROG='s/^\([^:][^:]*:[0-9]\{4\}\)[0-9]\.[0-9][0-9]*:.*$/\1x/p' 5 | 6 | xmldoc() 7 | { 8 | BAD="$1" 9 | DOCTYPE="$2" 10 | 11 | echo '' 12 | [ -n "$DOCTYPE" ] && echo "$DOCTYPE" 13 | echo '' 14 | ${AWK:-awk} 'BEGIN{for(i=0; i < 69999; i++) print ""}' < /dev/null 15 | echo "$BAD" 16 | echo '' 17 | } 18 | -------------------------------------------------------------------------------- /xmlstarlet/examples/bigxml-dtd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ./bigxml 3 | xmldoc 'foo' \ 4 | | ./xmlstarlet val --dtd dtd/bigxml.dtd --err - 2>&1 >/dev/null \ 5 | | ${SED:-sed} -n "$SEDLINUM_PROG" 6 | -------------------------------------------------------------------------------- /xmlstarlet/examples/bigxml-embed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ./bigxml 3 | xmldoc ' foo ' \ 4 | ' ]>' \ 5 | | ./xmlstarlet val --embed --err - \ 6 | 2>&1 >/dev/null | ${SED:-sed} -n "$SEDLINUM_PROG" 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/bigxml-embed-ref: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ./bigxml 3 | xmldoc 'foo' '' \ 4 | | ./xmlstarlet val --embed --err - 2>&1 >/dev/null \ 5 | | ${SED:-sed} -n "$SEDLINUM_PROG" \ 6 | | head -n 1 # a bug in libxml 2.9.0 causes extra errors to be 7 | # printed, so we take just the first 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/bigxml-relaxng: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ./bigxml 3 | xmldoc ' foo ' | ./xmlstarlet val --relaxng relaxng/bigxml.rng --err - \ 4 | 2>&1 >/dev/null | ${SED:-sed} -n "$SEDLINUM_PROG" 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/bigxml-well-formed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ./bigxml 3 | xmldoc '' | ./xmlstarlet val --well-formed --err - \ 4 | 2>&1 >/dev/null | ${SED:-sed} -n "$SEDLINUM_PROG" 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/bigxml-xsd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ./bigxml 3 | xmldoc '' | ./xmlstarlet val --xsd xsd/bigxml.xsd --err - \ 4 | 2>&1 >/dev/null | ${SED:-sed} -n "$SEDLINUM_PROG" 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/c14n-default-attr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet c14n xml/c14n-default-attr.xml 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/c14n-newlines: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet c14n xml/c14n.xml | tr '\r' R | grep R 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/c14n1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # XML canonicalization 3 | ./xmlstarlet c14n --with-comments ../examples/xml/structure.xml ; echo $? 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/c14n2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # XML exclusive canonicalization 3 | ./xmlstarlet c14n --exc-with-comments ../examples/xml/c14n.xml ../examples/xml/c14n.xpath 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/command-help: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -n "$EXEEXT" ] && [ "$OSTYPE" = MSYS ] ; then 4 | EXEEXT=.exe 5 | fi 6 | 7 | for command in ed sel tr val fo el c14n ls esc unesc pyx p2x ; do 8 | ./xmlstarlet $command --help | ${SED:-sed} -n \ 9 | "s@^\\(Usage: \\).*xml$EXEEXT\\( $command\\).*@\\1xml\\2@p" 10 | done 11 | -------------------------------------------------------------------------------- /xmlstarlet/examples/count1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Count elements matching XPath expression 3 | ./xmlstarlet sel -T -t -v "count(/xml/table/rec/numField)" xml/table.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/countnode1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Count all nodes in XML document 3 | ./xmlstarlet sel -T -t -f -o " " -v "count(//node())" --nl xml/table.xml xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/delete1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Delete elements matching XPath expression 3 | ./xmlstarlet ed -d '/xml/table/rec[@id="2"]' xml/table.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/docbook1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Generate HTML from given SGML docbook document 3 | ./xmlstarlet tr --omit-decl --docbook /usr/share/sgml/docbook/yelp/docbook/html/docbook.xsl sgml/docbook1.sgml | \ 4 | ./xmlstarlet fo --html --indent-spaces 2 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/dtd/bigxml.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/dtd/tab-obj.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /xmlstarlet/examples/dtd/table.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /xmlstarlet/examples/dtd1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Validate XML document against DTD 3 | ./xmlstarlet val --dtd dtd/table.dtd xml/tab-obj.xml >/dev/null 2>&1; echo $? 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/dtd2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Validate XML document against DTD 3 | ./xmlstarlet val --dtd dtd/table.dtd xml/table.xml >/dev/null 2>&1; echo $? 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/dtd3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Validate XML document against DTD 3 | ./xmlstarlet val --dtd xml/foo.dtd xml/foo.xml 2>/dev/null 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/dtd4: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # make sure we don't look for embedded dtd if not asked 3 | ./xmlstarlet val --dtd dtd/table.dtd xml/table.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-2op: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed -a '/xml/table/rec[@id=1]' -t elem -n newrec -v value -d '/xml/table/rec[@id!=1]' xml/table.xml 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-append: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed -a '/xml/table/rec[@id=1]' -t elem -n newrec -v value xml/table.xml 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-backref-delete: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed \ 3 | -s /xml/table/rec -t elem -n new-field -v new-value \ 4 | -d '$prev' \ 5 | -i '$prev' -t attr -n new-attr -v new-attr-value \ 6 | xml/table.xml 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-backref1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed \ 3 | -s /xml/table/rec -t elem -n new-field -v new-value \ 4 | -i '$prev' -t attr -n new-attr -v new-attr-value \ 5 | xml/table.xml 6 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-backref2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed \ 3 | -s /xml/table/rec -t elem -n new-field -v new-value \ 4 | --var new-field '$prev' \ 5 | -i '$new-field' -t attr -n new-attr -v new-attr-value \ 6 | -s '$new-field' -t elem -n new-subelem -v '' \ 7 | xml/table.xml | ./xmlstarlet c14n 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-expr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed \ 3 | -u /xml/table/rec/@id -x .+1 \ 4 | -a /xml/table -t elem -n highest-record -v '' \ 5 | -u '$xstar:prev' -x '/xml/table/rec[numField=math:max(../rec/numField)]' \ 6 | xml/table.xml 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-insert: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed -i '/xml/table/rec[@id=1]' -t attr -n first -v yes xml/table.xml 3 | # insert empty element 4 | ./xmlstarlet ed -i '/foo' -t elem -n first xml/entity.xml -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-literal: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed -u /doc -v '"<>& " & < >' xml/foo.xml 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-move: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed -m '/xml/table/rec[@id=1]/@id' '/xml/table' xml/table.xml 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-namespace: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed -d "//namespace::xsi" xml/S0.xml 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-nop: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # libxml2 returns a NULL nodeset instead of an empty nodeset for this 3 | # xpath expression 4 | ./xmlstarlet ed -S -N n=nn -d /n:doc/foo xml/foo.xml 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ed-subnode: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet ed -s '/xml/table/rec[@id=1]' -t elem -n newrec -v value xml/table.xml 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/elem-depth: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # display unique elements up to depth 2 3 | ./xmlstarlet el -d2 ./xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/elem-uniq: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # display unique elements 3 | ./xmlstarlet el -u ./xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/elem1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Display element structure of XML document 3 | ./xmlstarlet el ./xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/elem2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Display element structure of XML document (including attributes) 3 | ./xmlstarlet el -a ./xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/elem3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Display element structure of XML document (including attribute values) 3 | ./xmlstarlet el -v ./xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/escape1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Escape special XML characters 3 | cat xml/structure.xml | ./xmlstarlet esc 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/exslt-ed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Use EXSLT functions 3 | echo '' | ./xmlstarlet ed -O -u /x -x 'date:day-name("2011-09-24")' 4 | echo '' | ./xmlstarlet ed -O -u /x -x 'math:abs(-1000)' 5 | echo 'aba' | ./xmlstarlet ed -O -u /x -x 'count(set:distinct(/x/*))' 6 | -------------------------------------------------------------------------------- /xmlstarlet/examples/exslt1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Calculate EXSLT (XSLT extentions) XPath value 3 | echo "" | ./xmlstarlet sel -T -t -v "math:abs(-1000)" --nl 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/findfile1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Find XML files matching XPath expression (containing 'object' element) 3 | ./xmlstarlet sel -T -t -m //object -f --nl xml/table.xml xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/foreach-literal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | the_test abc 3 | the_test "a'c" 4 | the_test 'a"c' 5 | the_test a\'\"c 6 | the_test \"\'a\'b\"\" 7 | the_test '!@#$%^&*()_+-=~`\|'\''";:/?.>,<[]{}' 8 | the_test ']]>' 9 | -------------------------------------------------------------------------------- /xmlstarlet/examples/foreach-xpath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | the_test "'abc'" 3 | the_test \"a\'c\" 4 | the_test \'a\"c\' 5 | the_test 'concat("a'\''", '\'\"c\'\) 6 | the_test 'concat('\'\"\',\ \"\'a\'b\",\ \'\"\"\'\) 7 | the_test 'concat("!@#$%^&*()_+-=~`\|'\'\",\''";:/?.>,<[]{}'\'\) 8 | the_test '"]]>"' 9 | -------------------------------------------------------------------------------- /xmlstarlet/examples/genxml1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Generate XML document using command line xml sel 3 | echo "" | ./xmlstarlet sel -t -m / -e xml -e child -a data -o value | ./xmlstarlet c14n 4 | echo 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/hello1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Apply XSLT stylesheet to HTML input file 3 | ./xmlstarlet tr --html xsl/hello1.xsl html/hello1.html 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/html/hello1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello World 4 | 5 | 6 | 7 |
Hello World!
8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /xmlstarlet/examples/j2ee/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TestServlet 6 | TestServlet 7 | 8 | 9 | TestServlet 10 | /TestServlet 11 | 12 | 13 | TestServlet.html 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /xmlstarlet/examples/localname1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Use local-name() XSLT function in XPath expression 3 | ./xmlstarlet sel -T -t -v "//*[local-name()='query']" --nl xsql/jobserve.xsql 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/look1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Select text value of an XML element mathing given XPath expression 3 | ./xmlstarlet sel -T -t -m "/xml/table/rec[@id='2']" -v numField --nl xml/table.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/move1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Move element node 3 | echo '' | ./xmlstarlet ed -m "//b" "//a" 4 | 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/noindent1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Format XML document disabling indent 3 | cat xml/tab-obj.xml | ./xmlstarlet fo --noindent 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/ns1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Predefine namespaces for XPath expressions 3 | ./xmlstarlet sel -T -N xsql=urn:oracle-xsql -t -v /xsql:query --nl xsql/jobserve.xsql 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/pyx: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet pyx xml/books.xml | ./xmlstarlet depyx | ./xmlstarlet c14n 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/pyx-ns: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet pyx xml/c14n.xml | ./xmlstarlet depyx | ./xmlstarlet c14n 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/rdf/em.rdf: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Eric Miller 6 | 7 | Dr. 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /xmlstarlet/examples/recover1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Recover malformed XML document 3 | ./xmlstarlet fo -R xml/malformed.xml 2>/dev/null 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/relaxng/address-bad.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John Smith 4 | js@example.com 5 | 6 | 7 | Fred Bloggs 8 | fb@example.net 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /xmlstarlet/examples/relaxng/address.rng: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /xmlstarlet/examples/relaxng/address.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | John Smith 4 | js@example.com 5 | 6 | 7 | Fred Bloggs 8 | fb@example.net 9 | 10 | 11 | -------------------------------------------------------------------------------- /xmlstarlet/examples/relaxng/bigxml.rng: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /xmlstarlet/examples/rename-attr1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Rename attributes 3 | ./xmlstarlet ed -r "//*/@id" -v ID xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/rename-elem1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Rename elements 3 | ./xmlstarlet ed -r "/xml/table/rec" -v record xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/N-order.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimitern/xmlstarlet/40147930485bc910130268923ecf9500a3879046/xmlstarlet/examples/results/N-order.out -------------------------------------------------------------------------------- /xmlstarlet/examples/results/bigxml-dtd.out: -------------------------------------------------------------------------------- 1 | -:7000x 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/bigxml-embed-ref.out: -------------------------------------------------------------------------------- 1 | -:7000x 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/bigxml-embed.out: -------------------------------------------------------------------------------- 1 | -:7000x 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/bigxml-relaxng.out: -------------------------------------------------------------------------------- 1 | -:7000x 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/bigxml-well-formed.out: -------------------------------------------------------------------------------- 1 | -:7000x 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/bigxml-xsd.out: -------------------------------------------------------------------------------- 1 | -:7000x 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/bigxml.out: -------------------------------------------------------------------------------- 1 | -:7000x 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/c14n-default-attr.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/c14n-newlines.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimitern/xmlstarlet/40147930485bc910130268923ecf9500a3879046/xmlstarlet/examples/results/c14n-newlines.out -------------------------------------------------------------------------------- /xmlstarlet/examples/results/c14n1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 0 15 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/c14n2.out: -------------------------------------------------------------------------------- 1 | 2 | content 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/command-help.out: -------------------------------------------------------------------------------- 1 | Usage: xml ed 2 | Usage: xml sel 3 | Usage: xml tr 4 | Usage: xml val 5 | Usage: xml fo 6 | Usage: xml el 7 | Usage: xml c14n 8 | Usage: xml ls 9 | Usage: xml esc 10 | Usage: xml unesc 11 | Usage: xml pyx 12 | Usage: xml p2x 13 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/count1.out: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /xmlstarlet/examples/results/countnode1.out: -------------------------------------------------------------------------------- 1 | xml/table.xml 32 2 | xml/tab-obj.xml 41 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/delete1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 9 | -23 10 | stringValue 11 | 12 |
13 |
14 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/docbook1.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimitern/xmlstarlet/40147930485bc910130268923ecf9500a3879046/xmlstarlet/examples/results/docbook1.out -------------------------------------------------------------------------------- /xmlstarlet/examples/results/dtd1.out: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/dtd2.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/dtd3.out: -------------------------------------------------------------------------------- 1 | xml/foo.xml - invalid 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/dtd4.out: -------------------------------------------------------------------------------- 1 | xml/table.xml - valid 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-2op.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | value 9 |
10 |
11 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-append.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | value 9 | 10 | 346 11 | Text Value 12 | 13 | 14 | -23 15 | stringValue 16 | 17 |
18 |
19 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-backref-delete.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 9 | 346 10 | Text Value 11 | 12 | 13 | -23 14 | stringValue 15 | 16 |
17 |
18 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-backref1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | new-value 8 | 9 | 10 | 346 11 | Text Value 12 | new-value 13 | 14 | 15 | -23 16 | stringValue 17 | new-value 18 | 19 |
20 |
21 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-backref2.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 123 5 | String Value 6 | new-value 7 | 8 | 9 | 346 10 | Text Value 11 | new-value 12 | 13 | 14 | -23 15 | stringValue 16 | new-value 17 | 18 |
19 |
-------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-expr.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 9 | 346 10 | Text Value 11 | 12 | 13 | -23 14 | stringValue 15 | 16 |
17 | 18 | 19 | 346 20 | Text Value 21 | 22 | 23 |
24 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-insert.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 9 | 346 10 | Text Value 11 | 12 | 13 | -23 14 | stringValue 15 | 16 |
17 |
18 | 19 | 20 | bar 21 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-literal.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | "<>& &quot; &amp; &lt; &gt; 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-move.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 9 | 346 10 | Text Value 11 | 12 | 13 | -23 14 | stringValue 15 | 16 |
17 |
18 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-namespace.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-nop.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This is a "foo" line. 5 | This is a "bar" line. 6 | This is another "foo" line. 7 | 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ed-subnode.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | value 8 | 9 | 10 | 346 11 | Text Value 12 | 13 | 14 | -23 15 | stringValue 16 | 17 |
18 |
19 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/elem-depth.out: -------------------------------------------------------------------------------- 1 | xml 2 | xml/table 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/elem-uniq.out: -------------------------------------------------------------------------------- 1 | xml 2 | xml/table 3 | xml/table/rec 4 | xml/table/rec/numField 5 | xml/table/rec/object 6 | xml/table/rec/object/property 7 | xml/table/rec/stringField 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/elem1.out: -------------------------------------------------------------------------------- 1 | xml 2 | xml/table 3 | xml/table/rec 4 | xml/table/rec/numField 5 | xml/table/rec/stringField 6 | xml/table/rec/object 7 | xml/table/rec/object/property 8 | xml/table/rec/object/property 9 | xml/table/rec 10 | xml/table/rec/numField 11 | xml/table/rec/stringField 12 | xml/table/rec 13 | xml/table/rec/numField 14 | xml/table/rec/stringField 15 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/elem2.out: -------------------------------------------------------------------------------- 1 | xml 2 | xml/table 3 | xml/table/rec 4 | xml/table/rec/@id 5 | xml/table/rec/numField 6 | xml/table/rec/stringField 7 | xml/table/rec/object 8 | xml/table/rec/object/@name 9 | xml/table/rec/object/property 10 | xml/table/rec/object/property/@name 11 | xml/table/rec/object/property 12 | xml/table/rec/object/property/@name 13 | xml/table/rec 14 | xml/table/rec/@id 15 | xml/table/rec/numField 16 | xml/table/rec/stringField 17 | xml/table/rec 18 | xml/table/rec/@id 19 | xml/table/rec/numField 20 | xml/table/rec/stringField 21 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/elem3.out: -------------------------------------------------------------------------------- 1 | xml 2 | xml/table 3 | xml/table/rec[@id='1'] 4 | xml/table/rec/numField 5 | xml/table/rec/stringField 6 | xml/table/rec/object[@name='Obj1'] 7 | xml/table/rec/object/property[@name='size'] 8 | xml/table/rec/object/property[@name='type'] 9 | xml/table/rec[@id='2'] 10 | xml/table/rec/numField 11 | xml/table/rec/stringField 12 | xml/table/rec[@id='3'] 13 | xml/table/rec/numField 14 | xml/table/rec/stringField 15 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/escape1.out: -------------------------------------------------------------------------------- 1 | <a1> 2 | <a11> 3 | <a111> 4 | <a1111/> 5 | </a111> 6 | <a112> 7 | <a1121/> 8 | </a112> 9 | </a11> 10 | <a12/> 11 | <a13> 12 | <a131/> 13 | </a13> 14 | </a1> 15 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/exslt-ed.out: -------------------------------------------------------------------------------- 1 | Saturday 2 | 1000 3 | 2 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/exslt1.out: -------------------------------------------------------------------------------- 1 | 1000 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/external-entity.out: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/findfile1.out: -------------------------------------------------------------------------------- 1 | xml/tab-obj.xml 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/genxml1.out: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/hello1.out: -------------------------------------------------------------------------------- 1 | Hello World! -------------------------------------------------------------------------------- /xmlstarlet/examples/results/localname1.out: -------------------------------------------------------------------------------- 1 | 2 | SELECT substr(title,1,26) short_title, title, location, skills 3 | FROM job 4 | WHERE UPPER(title) LIKE '%ORACLE%' 5 | ORDER BY first_posted DESC 6 | 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/look1.out: -------------------------------------------------------------------------------- 1 | 346 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/move1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |
7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/noindent1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 10 9 | Data 10 | 11 | 12 | 13 | 346 14 | Text Value 15 | 16 | 17 | -23 18 | stringValue 19 | 20 |
21 |
22 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/ns1.out: -------------------------------------------------------------------------------- 1 | 2 | SELECT substr(title,1,26) short_title, title, location, skills 3 | FROM job 4 | WHERE UPPER(title) LIKE '%ORACLE%' 5 | ORDER BY first_posted DESC 6 | 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/pyx-ns.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | content 4 | 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/pyx.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Atlas Shrugged 5 | Ayn Rand 6 | 0525934189

7 |
8 | Next Book 9 | 10 | A Burnt-Out Case 11 | Graham Greene 12 | 0140185399

13 |
14 |
-------------------------------------------------------------------------------- /xmlstarlet/examples/results/recover1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | foo 4 | ... 5 | 6 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/rename-attr1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 10 9 | Data 10 | 11 | 12 | 13 | 346 14 | Text Value 15 | 16 | 17 | -23 18 | stringValue 19 | 20 |
21 |
22 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/rename-elem1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 10 9 | Data 10 | 11 | 12 | 13 | 346 14 | Text Value 15 | 16 | 17 | -23 18 | stringValue 19 | 20 |
21 |
22 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/schema1.out: -------------------------------------------------------------------------------- 1 | xml/tab-obj.xml 2 | 1 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sel-if.out: -------------------------------------------------------------------------------- 1 | yes 2 | all 3 | no 4 | all 5 | maybe 6 | all 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sel-literal.out: -------------------------------------------------------------------------------- 1 | abc 2 | a'c 3 | a"c 4 | a'"c 5 | "'a'b"" 6 | !@#$%^&*()_+-=~`\|'";:/?.>,<[]{} 7 | ]]> 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sel-many-values.out: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sel-root.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sel-xpath-c.out: -------------------------------------------------------------------------------- 1 | abc 2 | a'c 3 | a"c 4 | a'"c 5 | "'a'b"" 6 | !@#$%^&*()_+-=~`\|'";:/?.>,<[]{} 7 | ]]> 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sel-xpath-i.out: -------------------------------------------------------------------------------- 1 | abc 2 | a'c 3 | a"c 4 | a'"c 5 | "'a'b"" 6 | !@#$%^&*()_+-=~`\|'";:/?.>,<[]{} 7 | ]]> 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sel-xpath-m.out: -------------------------------------------------------------------------------- 1 | abc 2 | a'c 3 | a"c 4 | a'"c 5 | "'a'b"" 6 | !@#$%^&*()_+-=~`\|'";:/?.>,<[]{} 7 | ]]> 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sel-xpath-v.out: -------------------------------------------------------------------------------- 1 | abc 2 | a'c 3 | a"c 4 | a'"c 5 | "'a'b"" 6 | !@#$%^&*()_+-=~`\|'";:/?.>,<[]{} 7 | ]]> 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sel1.out: -------------------------------------------------------------------------------- 1 | 123String Value 2 | 346Text Value 3 | -23stringValue 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sort1.out: -------------------------------------------------------------------------------- 1 | 3|-23|stringValue 2 | 2|346|Text Value 3 | 1|123|String Value 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sort2.out: -------------------------------------------------------------------------------- 1 | A 2 | a 3 | E 4 | e 5 | B 6 | b 7 | C 8 | c 9 | D 10 | d 11 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sort3.out: -------------------------------------------------------------------------------- 1 | a 2 | A 3 | b 4 | B 5 | c 6 | C 7 | d 8 | D 9 | e 10 | E 11 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/structure1.out: -------------------------------------------------------------------------------- 1 | a1 2 | a1.a11 3 | a1.a11.a111 4 | a1.a11.a111.a1111 5 | a1.a11.a112 6 | a1.a11.a112.a1121 7 | a1.a12 8 | a1.a13 9 | a1.a13.a131 10 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/sum1.out: -------------------------------------------------------------------------------- 1 | 446 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/tab1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 10 9 | Data 10 | 11 | 12 | 13 | 346 14 | Text Value 15 | 16 | 17 | -23 18 | stringValue 19 | 20 |
21 |
22 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/table1.out: -------------------------------------------------------------------------------- 1 | 1|123|String Value 2 | 2|346|Text Value 3 | 3|-23|stringValue 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/table2.out: -------------------------------------------------------------------------------- 1 | 1|123|String Value 2 | 2|346|Text Value 3 | 3|-23|stringValue 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/table3.out: -------------------------------------------------------------------------------- 1 | =================== 2 | 1|123|String Value 3 | 2|346|Text Value 4 | 3|-23|stringValue 5 | =================== 6 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/tree1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 0525934189 5 | 6 | 7 | 0140185399 8 | 9 | 10 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/unicode1.out: -------------------------------------------------------------------------------- 1 | français 2 | français 3 | français 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/update-attr1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 10 9 | Data 10 | 11 | 12 | 13 | 346 14 | Text Value 15 | 16 | 17 | -23 18 | stringValue 19 | 20 |
21 |
22 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/update-elem1.out: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 0 6 | String Value 7 | 8 | 10 9 | Data 10 | 11 | 12 | 13 | 346 14 | Text Value 15 | 16 | 17 | -23 18 | stringValue 19 | 20 |
21 |
22 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/valid1.out: -------------------------------------------------------------------------------- 1 | =============================================== 2 | Well-Formedness Validation Tests 3 | - 1 ------------------------------------------- 4 | xml/table.xml - valid 5 | xml/tab-obj.xml - valid 6 | xml/tab-bad.xml - invalid 7 | 1 8 | - 2 ------------------------------------------- 9 | xml/table.xml 10 | xml/tab-obj.xml 11 | 1 12 | - 3 ------------------------------------------- 13 | xml/tab-bad.xml 14 | 1 15 | - 4 ------------------------------------------- 16 | 0 17 | =============================================== 18 | DTD Validation Tests 19 | - 1 ------------------------------------------- 20 | xml/table.xml - valid 21 | xml/tab-obj.xml - invalid 22 | xml/tab-bad.xml - invalid 23 | 1 24 | - 2 ------------------------------------------- 25 | xml/table.xml 26 | 1 27 | - 3 ------------------------------------------- 28 | xml/tab-obj.xml 29 | xml/tab-bad.xml 30 | 1 31 | - 4 ------------------------------------------- 32 | 0 33 | =============================================== 34 | Schema Validation Tests 35 | - 1 ------------------------------------------- 36 | xml/table.xml - valid 37 | xml/tab-obj.xml - invalid 38 | xml/tab-bad.xml - invalid 39 | 1 40 | - 2 ------------------------------------------- 41 | xml/table.xml 42 | 1 43 | - 3 ------------------------------------------- 44 | xml/tab-obj.xml 45 | xml/tab-bad.xml 46 | 1 47 | - 4 ------------------------------------------- 48 | 0 49 | =============================================== 50 | RelaxNG Schema Validation Tests 51 | - 1 ------------------------------------------- 52 | relaxng/address.xml - valid 53 | relaxng/address-bad.xml - invalid 54 | 1 55 | - 2 ------------------------------------------- 56 | relaxng/address.xml 57 | 1 58 | - 3 ------------------------------------------- 59 | relaxng/address-bad.xml 60 | 1 61 | - 4 ------------------------------------------- 62 | 0 63 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/xinclude1.out: -------------------------------------------------------------------------------- 1 | 2 |

120 Mz is adequate for an average home user.

3 | 4 |

The opinions represented herein represent those of the individual 5 | and should not be interpreted as official policy endorsed by this 6 | organization.

7 |
8 |
-------------------------------------------------------------------------------- /xmlstarlet/examples/results/xsl-param1.out: -------------------------------------------------------------------------------- 1 | Count=3 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/results/xsl-sum1.out: -------------------------------------------------------------------------------- 1 | 446 2 | -------------------------------------------------------------------------------- /xmlstarlet/examples/schema1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Validate against XSD schema 3 | ./xmlstarlet val -b -s xsd/table.xsd xml/table.xml xml/tab-obj.xml 2>/dev/null; echo $? 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sel-if: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo '' | ./xmlstarlet sel -T -t -i 'true()' -o yes -n --else -o no -n -b -o all -n 3 | echo '' | ./xmlstarlet sel -T -t -i 'false()' -o yes -n --else -o no -n -b -o all -n 4 | echo '' | ./xmlstarlet sel -T -t -i 'false()' -o yes -n --elif 'true()' -o maybe -n --else -o no -n -b -o all -n 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sel-literal: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | the_test() { 3 | ./xmlstarlet sel --text -t -m /doc -o "$1" --nl xml/foo.xml 4 | } 5 | 6 | . "${srcdir-..}"/examples/foreach-literal.sh 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sel-many-values: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./xmlstarlet sel -T -t -v //@id xml/table.xml 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sel-root: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo '' | ./xmlstarlet sel --root -t -c / | ./xmlstarlet c14n 3 | echo 4 | echo '' | ./xmlstarlet sel --root -t -c / -t -c / | ./xmlstarlet c14n 5 | echo 6 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sel-xpath-c: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | the_test() { 3 | ./xmlstarlet sel --text -t -m /doc -c "$1" --nl xml/foo.xml 4 | } 5 | 6 | . "${srcdir-..}"/examples/foreach-xpath.sh 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sel-xpath-i: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | the_test() { 3 | ./xmlstarlet sel --text -t -i "$1" -v "$1" --nl xml/foo.xml 4 | } 5 | 6 | . "${srcdir-..}"/examples/foreach-xpath.sh 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sel-xpath-m: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | the_test() { 3 | ./xmlstarlet sel --text -t -m "/*[boolean($1)]" -v "$1" --nl xml/foo.xml 4 | } 5 | 6 | . "${srcdir-..}"/examples/foreach-xpath.sh 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sel-xpath-v: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | the_test() { 3 | ./xmlstarlet sel --text -t -m /doc -v "$1" --nl xml/foo.xml 4 | } 5 | 6 | . "${srcdir-..}"/examples/foreach-xpath.sh 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sel1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # xsl:copy-of in xml sel command 3 | ./xmlstarlet sel -B -t -e ROOT -m /xml/table/rec -c . -n xml/table.xml | ./xmlstarlet c14n 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sgml/docbook1.sgml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | DocBook document example 8 | 9 | Mikhail 10 | Grushinskiy 11 | 12 | 13 | 14 | 2002 15 | Mikhail Grushinskiy 16 | 17 | 18 | 19 | 20 | Sample document 21 | 22 | A simple DocBook example document. 23 | 24 | 25 | 26 | XMLStarlet Example 27 | 28 | The XMLStarlet command line toolkit 29 | allows querying/checking/editing/transforming/formatting XML documents 30 | from command line 31 | 32 | To find out more on how to use the 33 | XMLStarlet for XML processing, point 34 | your browser to http://xmlstar.sourceforge.net/. 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sort1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Query XML document and produce sorted text table 3 | ./xmlstarlet sel -T -t -m /xml/table/rec -s D:N:- "@id" -v "concat(@id,'|',numField,'|',stringField)" -n xml/table.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sort2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Sort on two fields 3 | ./xmlstarlet sel -T -t -m /root/elem -s A:N:U @rank -s A:T:U @name -v @name -n xml/unsorted.xml 4 | 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sort3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # lower case first 3 | ./xmlstarlet sel -T -t -m /root/elem -s A:T:L @name -v @name -n xml/unsorted.xml 4 | 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/structure1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Print structure of XML element using xml sel (advanced XPath expressions and xml sel command usage) 3 | ./xmlstarlet sel -T -t -m '//*' \ 4 | -m 'ancestor-or-self::*' -v 'name()' -i 'not(position()=last())' -o . -b -b -n \ 5 | xml/structure.xml 6 | -------------------------------------------------------------------------------- /xmlstarlet/examples/sum1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Calculating running sum on XML document 3 | ./xmlstarlet sel -T -t -v "sum(/xml/table/rec/numField)" --nl xml/table.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/svg/sample.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Four separate rectangles 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | -------------------------------------------------------------------------------- /xmlstarlet/examples/tab1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Indent XML document with tabs 3 | cat xml/tab-obj.xml | ./xmlstarlet fo --indent-tab 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/table1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Generate plain text table from XML document 3 | ./xmlstarlet sel -T -t -m /xml/table/rec -v "@id" -o "|" -v numField -o "|" -v stringField -n xml/table.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/table2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Generate plain text table from XML document 3 | ./xmlstarlet sel -T -t -m /xml/table/rec -v "concat(@id,'|',numField,'|',stringField)" -n xml/table.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/table3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Generate plain text table from XML document 3 | ./xmlstarlet sel -T \ 4 | -t -o "===================" -n \ 5 | -m xml/table/rec -v "concat(@id,'|',numField,'|',stringField)" -n \ 6 | -t -o "===================" -n xml/table.xml 7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/tests.mk: -------------------------------------------------------------------------------- 1 | AM_TESTS_ENVIRONMENT = abs_builddir=$(abs_builddir) \ 2 | EXEEXT=$(EXEEXT) SED=$(SED) AWK=$(AWK) SHELL=$(SHELL); \ 3 | export abs_buildir; export EXEEXT; export SED; export AWK; export SHELL; 4 | 5 | LOG_COMPILER = $(SHELL) $(srcdir)/tests/runTest.sh 6 | 7 | # split tests into fast and slow, so we can run just the fast ones 8 | 9 | SLOW_TESTS =\ 10 | examples/bigxml-dtd\ 11 | examples/bigxml-embed-ref\ 12 | examples/bigxml-embed\ 13 | examples/bigxml-relaxng\ 14 | examples/bigxml-well-formed\ 15 | examples/bigxml-xsd 16 | 17 | QUICK_TESTS =\ 18 | examples/c14n-default-attr\ 19 | examples/c14n-newlines\ 20 | examples/c14n1\ 21 | examples/c14n2\ 22 | examples/command-help\ 23 | examples/count1\ 24 | examples/countnode1\ 25 | examples/delete1\ 26 | examples/dtd1\ 27 | examples/dtd2\ 28 | examples/dtd3\ 29 | examples/dtd4\ 30 | examples/ed-2op\ 31 | examples/ed-append\ 32 | examples/ed-backref-delete\ 33 | examples/ed-backref1\ 34 | examples/ed-backref2\ 35 | examples/ed-expr\ 36 | examples/ed-insert\ 37 | examples/ed-literal\ 38 | examples/ed-move\ 39 | examples/ed-namespace\ 40 | examples/ed-nop\ 41 | examples/ed-subnode\ 42 | examples/elem1\ 43 | examples/elem2\ 44 | examples/elem3\ 45 | examples/elem-depth\ 46 | examples/elem-uniq\ 47 | examples/escape1\ 48 | examples/exslt-ed\ 49 | examples/exslt1\ 50 | examples/findfile1\ 51 | examples/genxml1\ 52 | examples/hello1\ 53 | examples/localname1\ 54 | examples/look1\ 55 | examples/move1\ 56 | examples/N-order\ 57 | examples/noindent1\ 58 | examples/ns1\ 59 | examples/pyx\ 60 | examples/pyx-ns\ 61 | examples/recover1\ 62 | examples/rename-attr1\ 63 | examples/rename-elem1\ 64 | examples/schema1\ 65 | examples/sel-literal\ 66 | examples/sel-if\ 67 | examples/sel-many-values\ 68 | examples/sel-root\ 69 | examples/sel-xpath-c\ 70 | examples/sel-xpath-i\ 71 | examples/sel-xpath-m\ 72 | examples/sel-xpath-v\ 73 | examples/sel1\ 74 | examples/sort1\ 75 | examples/sort2\ 76 | examples/sort3\ 77 | examples/structure1\ 78 | examples/sum1\ 79 | examples/tab1\ 80 | examples/table1\ 81 | examples/table2\ 82 | examples/table3\ 83 | examples/unicode1\ 84 | examples/update-attr1\ 85 | examples/update-elem1\ 86 | examples/valid1\ 87 | examples/xinclude1\ 88 | examples/xsl-param1\ 89 | examples/xsl-sum1 90 | 91 | # default to all the tests 92 | TESTS = $(SLOW_TESTS) $(QUICK_TESTS) 93 | 94 | # qcheck is just tests listed in QUICK_TESTS 95 | qcheck : 96 | @$(MAKE) TESTS="$(QUICK_TESTS)" check 97 | 98 | XFAIL_TESTS =\ 99 | examples/bigxml-dtd\ 100 | examples/ed-namespace 101 | 102 | if !HAVE_EXSLT_XPATH_REGISTER 103 | XFAIL_TESTS += examples/exslt-ed 104 | endif 105 | -------------------------------------------------------------------------------- /xmlstarlet/examples/tree1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Print subtree of elements having given element as a descendant (advanced XPath) 3 | ./xmlstarlet ed -d '//node()[not(descendant-or-self::isbn or parent::isbn)] | //*[parent::isbn]' xml/books.xml 4 | 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/unicode1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Select from XML document containing unicode characters 3 | ./xmlstarlet sel -T -t -m "//test[@lang='français']/@lang" -v . -n xml/unicode.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/update-attr1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Update value of an attribute 3 | ./xmlstarlet ed -u '/xml/table/rec[@id=3]/@id' -v 5 xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/update-elem1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Update value of an element 3 | ./xmlstarlet ed -u '/xml/table/rec[@id=1]/numField' -v 0 xml/tab-obj.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/valid1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Validate XML documents using well-formedness/DTD/XSD/RelaxNG checks 3 | echo "===============================================" 4 | echo "Well-Formedness Validation Tests" 5 | echo "- 1 -------------------------------------------" 6 | ./xmlstarlet val xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? 7 | echo "- 2 -------------------------------------------" 8 | ./xmlstarlet val -g xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? 9 | echo "- 3 -------------------------------------------" 10 | ./xmlstarlet val -b xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? 11 | echo "- 4 -------------------------------------------" 12 | ./xmlstarlet val -q xml/table.xml xml/tab-obj.xml 2>/dev/null; echo $? 13 | 14 | echo "===============================================" 15 | echo "DTD Validation Tests" 16 | echo "- 1 -------------------------------------------" 17 | ./xmlstarlet val -d dtd/table.dtd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? 18 | echo "- 2 -------------------------------------------" 19 | ./xmlstarlet val -g -d dtd/table.dtd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? 20 | echo "- 3 -------------------------------------------" 21 | ./xmlstarlet val -b -d dtd/table.dtd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? 22 | echo "- 4 -------------------------------------------" 23 | ./xmlstarlet val -q -d dtd/table.dtd xml/table.xml 2>/dev/null; echo $? 24 | 25 | echo "===============================================" 26 | echo "Schema Validation Tests" 27 | echo "- 1 -------------------------------------------" 28 | ./xmlstarlet val -s xsd/table.xsd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? 29 | echo "- 2 -------------------------------------------" 30 | ./xmlstarlet val -g -s xsd/table.xsd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? 31 | echo "- 3 -------------------------------------------" 32 | ./xmlstarlet val -b -s xsd/table.xsd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? 33 | echo "- 4 -------------------------------------------" 34 | ./xmlstarlet val -q -s xsd/table.xsd xml/table.xml 2>/dev/null; echo $? 35 | 36 | echo "===============================================" 37 | echo "RelaxNG Schema Validation Tests" 38 | echo "- 1 -------------------------------------------" 39 | ./xmlstarlet val -r relaxng/address.rng relaxng/address.xml relaxng/address-bad.xml 2>/dev/null; echo $? 40 | echo "- 2 -------------------------------------------" 41 | ./xmlstarlet val -g -r relaxng/address.rng relaxng/address.xml relaxng/address-bad.xml 2>/dev/null; echo $? 42 | echo "- 3 -------------------------------------------" 43 | ./xmlstarlet val -b -r relaxng/address.rng relaxng/address.xml relaxng/address-bad.xml 2>/dev/null; echo $? 44 | echo "- 4 -------------------------------------------" 45 | ./xmlstarlet val -q -r relaxng/address.rng relaxng/address.xml 2>/dev/null; echo $? 46 | -------------------------------------------------------------------------------- /xmlstarlet/examples/vxml/root.vxml: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |
8 |
9 | -------------------------------------------------------------------------------- /xmlstarlet/examples/wsdl/quote.wsdl: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | My first service 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xinclude1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Include one XML document into another using XInclude 3 | ./xmlstarlet tr --xinclude xsl/cat.xsl xml/document.xml | ./xmlstarlet c14n 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xmi/example.xmi: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/S0.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/books.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Atlas Shrugged 6 | Ayn Rand 7 | 0525934189
8 |
9 | Next Book 10 | 11 | A Burnt-Out Case 12 | Graham Greene 13 | 0140185399
14 |
15 |
16 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/c14n-default-attr.xml: -------------------------------------------------------------------------------- 1 | ]> 2 | 3 | 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/c14n.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | content 4 | 5 | 6 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/c14n.xpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | (//. | //@* | //namespace::*)[ancestor-or-self::n1:elem1] 4 | 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/disclaimer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |

The opinions represented herein represent those of the individual 4 | and should not be interpreted as official policy endorsed by this 5 | organization.

6 |
7 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/document.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |

120 Mz is adequate for an average home user.

4 | 5 |
6 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/entity.xml: -------------------------------------------------------------------------------- 1 | 2 | bar 3 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/external-pe.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | ]> 7 | 8 | &entity; 9 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/foo.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/foo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This is a "foo" line. 5 | This is a "bar" line. 6 | This is another "foo" line. 7 | 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/malformed.xml: -------------------------------------------------------------------------------- 1 | 2 | foo 3 | ... 4 | 5 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/structure.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/tab-bad.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 10 9 | Data 10 | 11 | 12 | 13 | 346 14 | Text Value 15 | 16 | 17 | -23 18 | stringValue 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/tab-obj.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 123 6 | String Value 7 | 8 | 10 9 | Data 10 | 11 | 12 | 13 | 346 14 | Text Value 15 | 16 | 17 | -23 18 | stringValue 19 | 20 |
21 |
22 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/table.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 123 6 | String Value 7 | 8 | 9 | 346 10 | Text Value 11 | 12 | 13 | -23 14 | stringValue 15 | 16 |
17 |
18 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/unicode.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | ]> 8 | 9 | UTF-8 character. 10 | numeric ref. 11 | entity ref. 12 | 13 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/unsorted.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xml/xmlstarlet-xsa.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | Mikhail Grushinskiy 8 | mgrouch@users.sourceforge.net 9 | http://xmlstar.sourceforge.net/ 10 | 11 | 12 | 13 | xmlstarlet 14 | 0.3.0 15 | 20030528 16 | http://xmlstar.sourceforge.net/ 17 | 18 | Changes since 0.2.0 19 | 1. Many improvements to 'edit' option 20 | 2. Improvements for namespaces support in 'select' option 21 | 3. Fixes for 'ls' option 22 | 4. New binaries for Solaris8-sparc/RedHat-7.3/Mandrake-9.1/ 23 | 5. Documentation and web site updates 24 | 6. Improved build scripts and make files 25 | 7. Additional examples and tests 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xmlstarlet: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exepath=`dirname $0` 3 | xml="${abs_builddir-$exepath/..}"/xml 4 | 5 | if [ x"$OSTYPE" = xmsys ] ; then 6 | exec "$exepath/xmlstarlet.msys" "$xml" "$@" 7 | fi 8 | 9 | if [ x"$VALGRIND" = xyes ] ; then 10 | exec valgrind --error-exitcode=99 --quiet ${VALGRIND_OPTS} "$xml" "$@" 11 | fi 12 | 13 | exec "$xml" "$@" 14 | 15 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xmlstarlet.msys: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | xml="$1" 4 | shift 5 | 6 | # MSYS does unix -> windows path conversion if there is a leading / 7 | # but not when the argument contains a semicolon, eg: /x -> 8 | # C:\Mingw\msys\1.0\x so we double all leading /'s to avoid this 9 | 10 | nargs=$# 11 | args=() 12 | for ((i = 0; i < nargs; i++)) ; do 13 | if [[ "$1" = /* ]] && [[ "$1" != *\;* ]] ; then 14 | args[$i]="/$1" 15 | else 16 | args[$i]="$1" 17 | fi 18 | shift 19 | done 20 | 21 | exec "$xml" "${args[@]}" 22 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xsd/bigxml.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xsd/table.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xsl-param1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Passing parameters to XSLT stylesheet 3 | ./xmlstarlet tr xsl/param1.xsl -p Count='count(/xml/table/rec)' -s Text="Count=" xml/table.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xsl-sum1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Applying XSLT stylesheet to XML document 3 | ./xmlstarlet tr xsl/sum1.xsl xml/table.xml 4 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xsl/cat.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xsl/hello1.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | - 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xsl/param1.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xsl/sum1.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | - 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xsp/dynamic.xsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | // Define a variable to hold the time of day 11 | Date now = new Date(); 12 | 13 | 14 |

15 | To the best of my knowledge, it's now 16 | 17 | now 18 |

19 |
20 |
21 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xsql/jobserve.xsql: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SELECT substr(title,1,26) short_title, title, location, skills 5 | FROM job 6 | WHERE UPPER(title) LIKE '%ORACLE%' 7 | ORDER BY first_posted DESC 8 | 9 | -------------------------------------------------------------------------------- /xmlstarlet/examples/xupdate/insxml.xup: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 2 7 | 8 | Susan 9 | Long 10 | 11 | Tucson 12 | Arizona 13 | United States 14 | 430-304-3040 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /xmlstarlet/m4/quiet-rule.m4: -------------------------------------------------------------------------------- 1 | # serial 1 -*- mode: autoconf -*- 2 | # SILENT_RULE(varname, [echo = varname]) 3 | # defines V_varname to use for silent make rules 4 | AC_DEFUN([np_SILENT_RULE],[dnl 5 | m4_pushdef([varname], $1)dnl 6 | m4_pushdef([echoname], [m4_default($2, varname)])dnl 7 | # make silent rule for $1 8 | AC_SUBST(V_[]varname, ["\$(V_[]varname[]_$AM_V)"])dnl 9 | AC_SUBST(V_[]varname[]_, ["\$(V_[]varname[]_$AM_DEFAULT_VERBOSITY)"])dnl 10 | AC_SUBST(V_[]varname[]_0, ['@echo " echoname [$]@";'])dnl 11 | m4_popdef([varname], [echoname])dnl 12 | ]) 13 | -------------------------------------------------------------------------------- /xmlstarlet/m4/xstar-check-libs.m4: -------------------------------------------------------------------------------- 1 | # serial 1 -*- mode: autoconf -*- 2 | 3 | # XSTAR_LIB_ARGS_WITH(LIBXXX, [with-src = []]) 4 | dnl pass [with-src] to get the --with-libxxx-src option 5 | AC_DEFUN([XSTAR_LIB_ARGS_WITH], 6 | [m4_pushdef([LIBXXX], $1)dnl 7 | m4_pushdef([libxxx], m4_tolower(LIBXXX))dnl 8 | AC_ARG_WITH(libxxx-prefix, 9 | AS_HELP_STRING(--with-libxxx-prefix=[PFX], 10 | Specify location of libxxx), 11 | [LIBXXX()_PREFIX="$withval"]) 12 | AC_ARG_WITH(libxxx-include-prefix, 13 | AS_HELP_STRING([--with-libxxx-include-prefix=[PFX]], 14 | Specify location of libxxx headers), 15 | [LIBXXX()_INCDIR="$withval"]) 16 | AC_ARG_WITH(libxxx-libs-prefix, 17 | AS_HELP_STRING([--with-libxxx-libs-prefix=[PFX]], 18 | Specify location of libxxx libs), 19 | [LIBXXX()_LIBDIR="$withval"]) 20 | m4_if($2, [with-src], 21 | [AC_ARG_WITH(libxxx-src, 22 | AS_HELP_STRING([--with-libxxx-src=[DIR]], 23 | For libxxx that's not installed yet (sets all three above)), 24 | [LIBXXX()_SRCDIR="$withval" 25 | LIBXXX()_LIBDIR="$LIBXXX()_SRCDIR/.libs"])]) 26 | m4_popdef([libxxx], [LIBXXX])]) 27 | 28 | # XSTAR_LIB_CHECK(LIBXXX, xxx-config) 29 | # set LIBXXX_INCDIR and LIBXXX_LIBDIR based on location of xxx-config 30 | # also check xxx-config --version against LIBXXX_REQUIRED_VERSION 31 | # Ignores xxx-config if LIBXXX_SRCDIR is set 32 | AC_DEFUN([XSTAR_LIB_CHECK], 33 | [m4_pushdef([LIBXXX], $1) 34 | m4_pushdef([libxxx], m4_tolower(LIBXXX)) 35 | m4_pushdef([xxx_config], $2) 36 | AS_IF([test "x$LIBXXX()_SRCDIR" != x], 37 | [AC_MSG_NOTICE([using libxxx src dir "$LIBXXX()_SRCDIR"]) 38 | AC_MSG_WARN([not checking libxxx version])], 39 | [AC_PATH_PROG(LIBXXX()_CONFIG, xxx_config(), 40 | [], [$LIBXXX()_PREFIX/bin$PATH_SEPARATOR$PATH]) 41 | AS_IF([test "x$LIBXXX()_CONFIG" = x], 42 | [AC_MSG_FAILURE([xxx_config not found, 43 | libxxx is not installed or LIBXXX()_PREFIX is not correctly defined])]) 44 | LIBXXX()_VERSION=$($LIBXXX()_CONFIG --version) 45 | AS_VERSION_COMPARE([$LIBXXX()_VERSION], [$LIBXXX()_REQUIRED_VERSION], 46 | [AC_MSG_ERROR([xmlstarlet needs at least libxxx version $LIBXXX()_REQUIRED_VERSION (http://www.xmlsoft.org/)])]) 47 | AC_MSG_NOTICE([using libxxx-$LIBXXX()_VERSION]) 48 | LIBXXX()_PREFIX=`AS_DIRNAME($LIBXXX()_CONFIG)` 49 | LIBXXX()_PREFIX=`AS_DIRNAME($LIBXXX()_PREFIX)` 50 | : ${LIBXXX()_LIBDIR="$LIBXXX()_PREFIX/lib"}]) 51 | m4_popdef([xxx_config], [libxxx], [LIBXXX])]) 52 | -------------------------------------------------------------------------------- /xmlstarlet/setup_msvc.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | choco install -y -r --no-progress tartool wget sed gawk 4 | 5 | set XML2_URL=https://download.gnome.org/sources/libxml2/2.9/ 6 | set XSLT_URL=https://download.gnome.org/sources/libxslt/1.1/ 7 | set XML2_TARBALL=libxml2-2.9.1.tar.xz 8 | set XSLT_TARBALL=libxslt-1.1.28.tar.xz 9 | 10 | set PREFIX=C:\opt 11 | 12 | if exist %PREFIX% rd /q /s %PREFIX% 13 | 14 | if exist _build rd /q /s _build 15 | md _build 16 | 17 | rem Kill Git's link.exe which shadows MSVC's link.exe 18 | if exist "C:\Program Files\Git\usr\bin\link.exe" del "C:\Program Files\Git\usr\bin\link.exe" 19 | if exist "C:\Program Files (x86)\Git\usr\bin\link.exe" del "C:\Program Files (x86)\Git\usr\bin\link.exe" 20 | 21 | echo Fetching sources for dependencies... 22 | cd _build\ 23 | 24 | wget -q --output-document=%XML2_TARBALL% %XML2_URL%%XML2_TARBALL% 25 | tar -xf %XML2_TARBALL% 26 | dir %XML2_TARBALL% 27 | 28 | wget -q --output-document=%XSLT_TARBALL% %XSLT_URL%%XSLT_TARBALL% 29 | tar -xf %XSLT_TARBALL% 30 | dir %XML2_TARBALL% 31 | 32 | echo Building libxml2... 33 | cd libxml2-2.9.1\win32 34 | 35 | cscript configure.js debug=no static=yes compiler=msvc iconv=no python=no prefix=%PREFIX% cruntime=/MT 36 | 37 | rem Patch the win32config.h / config.h to make it compatible with VS 2015+ (libxml2) 38 | type ..\include\win32config.h | sed -e "s/#define snprintf _snprintf//g" > ..\include\win32config.h.patch 39 | copy ..\include\win32config.h.patch ..\include\win32config.h 40 | del ..\include\win32config.h.patch 41 | 42 | type ..\config.h | sed -e "s/#define snprintf _snprintf//g" > ..\config.h.patch 43 | copy ..\config.h.patch ..\config.h 44 | del ..\config.h.patch 45 | 46 | nmake all 47 | nmake install 48 | cd ..\.. 49 | 50 | echo Building libxslt... 51 | cd libxslt-1.1.28\win32 52 | 53 | cscript configure.js debug=no static=yes compiler=msvc iconv=no debugger=no include=%PREFIX%\include\libxml2 lib=%PREFIX%\lib prefix=%PREFIX% cruntime=/MT 54 | 55 | rem Patch the win32config.h to make it compatible with VS 2015+ (libxslt) 56 | type ..\libxslt\win32config.h | sed -e "s/#define snprintf _snprintf//g" > ..\libxslt\win32config.h.patch 57 | copy ..\libxslt\win32config.h.patch ..\libxslt\win32config.h 58 | del ..\libxslt\win32config.h.patch 59 | 60 | rem Patch the Makefile to exclude unsupported /OPT:NOWIN98 link.exe option 61 | type Makefile | sed -e "s/LDFLAGS = .*OPT:NOWIN98//g" > Makefile.patch 62 | copy Makefile.patch Makefile 63 | del Makefile.patch 64 | 65 | nmake all 66 | nmake install 67 | cd ..\..\.. 68 | 69 | echo Building xmlstarlet... 70 | cd xmlstarlet\win32\ 71 | 72 | cscript configure.js include=%PREFIX%\include\libxml2 prefix=%PREFIX% static=yes debug=no arch=%PLATFORM_NAME% cruntime=/MT 73 | nmake all 74 | nmake install 75 | cd ..\.. 76 | -------------------------------------------------------------------------------- /xmlstarlet/solaris/package/sol8-sparc/build: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | /usr/bin/pkgmk -o 4 | 5 | CUR_DIR=`pwd` 6 | 7 | FILE=xmlstarlet 8 | PKG=SFxmlstar 9 | VERSION=`/usr/bin/pkgparam -d /var/spool/pkg SFxmlstar VERSION` 10 | ARCH=`/usr/bin/pkgparam -d /var/spool/pkg SFxmlstar ARCH` 11 | OS=sol8 12 | BASE=local 13 | FULL_FILE=${FILE}-${VERSION}-${OS}-${ARCH}-${BASE} 14 | 15 | /usr/bin/pkgtrans -s /var/spool/pkg ${CUR_DIR}/${FULL_FILE} ${PKG} 16 | 17 | /usr/bin/gzip ${FULL_FILE} 18 | 19 | -------------------------------------------------------------------------------- /xmlstarlet/solaris/package/sol8-sparc/pkginfo.in: -------------------------------------------------------------------------------- 1 | # $Id: pkginfo.in,v 1.1 2003/05/10 23:21:06 mgrouch Exp $ 2 | 3 | PKG=SFxmlstar 4 | NAME="xmlstarlet Command Line XML Toolkit" 5 | ARCH=sparc 6 | VERSION=@VERSION@ 7 | MAXINST=1 8 | CATEGORY=application 9 | DESC="XmlStarlet Command Line XML Toolkit" 10 | CLASSES=none 11 | VENDOR="http://xmlstar.sourceforge.net/" 12 | BASEDIR=/usr/local 13 | 14 | -------------------------------------------------------------------------------- /xmlstarlet/solaris/package/sol8-sparc/prototype: -------------------------------------------------------------------------------- 1 | i pkginfo 2 | d none bin ? ? ? 3 | d none man ? ? ? 4 | d none man/man1 ? ? ? 5 | f none bin/xml=../../../src/xml 0755 root bin 6 | f none man/man1/xmlstarlet.1=../../../doc/xmlstarlet.1 0644 root bin 7 | 8 | -------------------------------------------------------------------------------- /xmlstarlet/solaris/package/sol9-sparc/build: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | /usr/bin/pkgmk -o 4 | 5 | CUR_DIR=`pwd` 6 | 7 | FILE=xmlstarlet 8 | PKG=SFxmlstar 9 | VERSION=`/usr/bin/pkgparam -d /var/spool/pkg SFxmlstar VERSION` 10 | ARCH=`/usr/bin/pkgparam -d /var/spool/pkg SFxmlstar ARCH` 11 | OS=sol9 12 | BASE=local 13 | FULL_FILE=${FILE}-${VERSION}-${OS}-${ARCH}-${BASE} 14 | 15 | /usr/bin/pkgtrans -s /var/spool/pkg ${CUR_DIR}/${FULL_FILE} ${PKG} 16 | 17 | /usr/bin/gzip ${FULL_FILE} 18 | 19 | -------------------------------------------------------------------------------- /xmlstarlet/solaris/package/sol9-sparc/pkginfo.in: -------------------------------------------------------------------------------- 1 | # $Id: pkginfo.in,v 1.1 2004/02/05 03:02:31 mgrouch Exp $ 2 | 3 | PKG=SFxmlstar 4 | NAME="xmlstarlet Command Line XML Toolkit" 5 | ARCH=sparc 6 | VERSION=@VERSION@ 7 | MAXINST=1 8 | CATEGORY=application 9 | DESC="XmlStarlet Command Line XML Toolkit" 10 | CLASSES=none 11 | VENDOR="http://xmlstar.sourceforge.net/" 12 | BASEDIR=/usr/local 13 | 14 | -------------------------------------------------------------------------------- /xmlstarlet/solaris/package/sol9-sparc/prototype: -------------------------------------------------------------------------------- 1 | i pkginfo 2 | d none bin ? ? ? 3 | d none man ? ? ? 4 | d none man/man1 ? ? ? 5 | f none bin/xml=../../../src/xml 0755 root bin 6 | f none man/man1/xmlstarlet.1=../../../doc/xmlstarlet.1 0644 root bin 7 | 8 | -------------------------------------------------------------------------------- /xmlstarlet/src/c14n-usage.txt: -------------------------------------------------------------------------------- 1 | XMLStarlet Toolkit: XML canonicalization 2 | Usage: PROG c14n [--net] [] [] 3 | where 4 | - input XML document file name (stdin is used if '-') 5 | - XML file containing XPath expression for 6 | c14n XML canonicalization 7 | Example: 8 | 9 | 10 | (//. | //@* | //namespace::*)[ancestor-or-self::n1:elem1] 11 | 12 | 13 | - the list of inclusive namespace prefixes 14 | (only for exclusive canonicalization) 15 | Example: 'n1 n2' 16 | 17 | is one of following: 18 | --with-comments XML file canonicalization w comments (default) 19 | --without-comments XML file canonicalization w/o comments 20 | --exc-with-comments Exclusive XML file canonicalization w comments 21 | --exc-without-comments Exclusive XML file canonicalization w/o comments 22 | 23 | -------------------------------------------------------------------------------- /xmlstarlet/src/depyx-usage.txt: -------------------------------------------------------------------------------- 1 | XMLStarlet Toolkit: Convert PYX into XML 2 | Usage: PROG p2x [] 3 | where 4 | - input PYX document file name (stdin is used if missing) 5 | 6 | The PYX format is a line-oriented representation of 7 | XML documents that is derived from the SGML ESIS format. 8 | (see ESIS - ISO 8879 Element Structure Information Set spec, 9 | ISO/IEC JTC1/SC18/WG8 N931 (ESIS)) 10 | 11 | -------------------------------------------------------------------------------- /xmlstarlet/src/edit-usage.txt: -------------------------------------------------------------------------------- 1 | XMLStarlet Toolkit: Edit XML document(s) 2 | Usage: PROG ed {} [ ... ] 3 | where 4 | - global options for editing 5 | - input XML document file name/uri (stdin otherwise) 6 | 7 | are: 8 | -P, or -S - preserve whitespace nodes. 9 | (or --pf, --ps) Note that space between attributes is not preserved 10 | -O (or --omit-decl) - omit XML declaration () 11 | -L (or --inplace) - edit file inplace 12 | -N = - predefine namespaces (name without 'xmlns:') 13 | ex: xsql=urn:oracle-xsql 14 | Multiple -N options are allowed. 15 | -N options must be last global options. 16 | --net - allow network access 17 | --help or -h - display help 18 | 19 | where 20 | -d or --delete 21 | --var 22 | -i or --insert -t (--type) elem|text|attr -n [-v (--value) ] 23 | -a or --append -t (--type) elem|text|attr -n [-v (--value) ] 24 | -s or --subnode -t (--type) elem|text|attr -n [-v (--value) ] 25 | -m or --move 26 | -r or --rename -v 27 | -u or --update -v (--value) 28 | -x (--expr) 29 | 30 | -------------------------------------------------------------------------------- /xmlstarlet/src/elem-usage.txt: -------------------------------------------------------------------------------- 1 | XMLStarlet Toolkit: Display element structure of XML document 2 | Usage: PROG el [] 3 | where 4 | - input XML document file name (stdin is used if missing) 5 | is one of: 6 | -a - show attributes as well 7 | -v - show attributes and their values 8 | -u - print out sorted unique lines 9 | -d - print out sorted unique lines up to depth 10 | 11 | -------------------------------------------------------------------------------- /xmlstarlet/src/escape-usage.txt: -------------------------------------------------------------------------------- 1 | XMLStarlet Toolkit: Escape special XML characters 2 | Usage: PROG esc [] [] 3 | where are 4 | --help - print usage 5 | (TODO: more to be added in future) 6 | if is missing stdin is used instead. 7 | 8 | -------------------------------------------------------------------------------- /xmlstarlet/src/escape.h: -------------------------------------------------------------------------------- 1 | /* $Id: escape.h,v 1.2 2005/03/12 03:24:23 mgrouch Exp $ */ 2 | 3 | #ifndef __ESCAPE_H 4 | #define __ESCAPE_H 5 | 6 | /* 7 | 8 | XMLStarlet: Command Line Toolkit to query/edit/check/transform XML documents 9 | 10 | Copyright (c) 2004 Mikhail Grushinskiy. All Rights Reserved. 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. 29 | 30 | */ 31 | 32 | typedef enum { 33 | XML_C14N_NORMALIZE_ATTR = 0, 34 | XML_C14N_NORMALIZE_COMMENT = 1, 35 | XML_C14N_NORMALIZE_PI = 2, 36 | XML_C14N_NORMALIZE_TEXT = 3, 37 | XML_C14N_NORMALIZE_NOTHING = 4 38 | } xml_C14NNormalizationMode; 39 | 40 | extern xmlChar *xml_C11NNormalizeString(const xmlChar * input, 41 | xml_C14NNormalizationMode mode); 42 | 43 | #define xml_C11NNormalizeAttr( a ) \ 44 | xml_C11NNormalizeString((a), XML_C14N_NORMALIZE_ATTR) 45 | #define xml_C11NNormalizeComment( a ) \ 46 | xml_C11NNormalizeString((a), XML_C14N_NORMALIZE_COMMENT) 47 | #define xml_C11NNormalizePI( a ) \ 48 | xml_C11NNormalizeString((a), XML_C14N_NORMALIZE_PI) 49 | #define xml_C11NNormalizeText( a ) \ 50 | xml_C11NNormalizeString((a), XML_C14N_NORMALIZE_TEXT) 51 | 52 | #endif /* __ESCAPE_H */ 53 | -------------------------------------------------------------------------------- /xmlstarlet/src/format-usage.txt: -------------------------------------------------------------------------------- 1 | XMLStarlet Toolkit: Format XML document 2 | Usage: PROG fo [] 3 | where are 4 | -n or --noindent - do not indent 5 | -t or --indent-tab - indent output with tabulation 6 | -s or --indent-spaces - indent output with spaces 7 | -o or --omit-decl - omit xml declaration 8 | --net - allow network access 9 | -R or --recover - try to recover what is parsable 10 | -D or --dropdtd - remove the DOCTYPE of the input docs 11 | -C or --nocdata - replace cdata section with text nodes 12 | -N or --nsclean - remove redundant namespace declarations 13 | -e or --encode - output in the given encoding (utf-8, unicode...) 14 | #ifdef LIBXML_HTML_ENABLED 15 | -H or --html - input is HTML 16 | #endif 17 | -h or --help - print help 18 | 19 | -------------------------------------------------------------------------------- /xmlstarlet/src/ls-usage.txt: -------------------------------------------------------------------------------- 1 | XMLStarlet Toolkit: List directory as XML 2 | Usage: PROG ls [ | --help ] 3 | Lists current directory in XML format. 4 | Time is shown per ISO 8601 spec. 5 | 6 | -------------------------------------------------------------------------------- /xmlstarlet/src/pyx-usage.txt: -------------------------------------------------------------------------------- 1 | XMLStarlet Toolkit: Convert XML into PYX format (based on ESIS - ISO 8879) 2 | Usage: PROG pyx {} 3 | where 4 | - input XML document file name (stdin is used if missing) 5 | 6 | The PYX format is a line-oriented representation of 7 | XML documents that is derived from the SGML ESIS format. 8 | (see ESIS - ISO 8879 Element Structure Information Set spec, 9 | ISO/IEC JTC1/SC18/WG8 N931 (ESIS)) 10 | 11 | A non-validating, ESIS generating tool originally developed for 12 | pyxie project (see http://pyxie.sourceforge.net/) 13 | ESIS Generation by Sean Mc Grath http://www.digitome.com/sean.html 14 | 15 | -------------------------------------------------------------------------------- /xmlstarlet/src/select-usage.txt: -------------------------------------------------------------------------------- 1 | XMLStarlet Toolkit: Select from XML document(s) 2 | Usage: PROG sel {