rnginline


Namernginline JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/h4l/rnginline
SummaryFlatten multi-file RELAX NG schemas
upload_time2023-05-07 15:18:45
maintainer
docs_urlNone
authorHal Blackburn
requires_python>=3.7,<4.0
licenseApache-2.0
keywords relaxng inline lxml xml
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # rnginline: Flatten multi-file RELAX NG schemas

[![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/h4l/rnginline/main.yml?branch=main)](https://github.com/h4l/rnginline/actions)
[![PyPI](https://img.shields.io/pypi/v/rnginline)](https://pypi.org/project/rnginline/)
[![Read the Docs](https://img.shields.io/readthedocs/rnginline)](https://rnginline.readthedocs.io/en/latest/)

rnginline is a Python library and command-line tool for loading multi-file RELAX
NG schemas from arbitary URLs, and flattening them into a single RELAX NG
schema.

## Features

- Convert multi-file RNG schemas into one file **without breaking or
  restructuring the schemas**
  - Great care is taken to maintain the semantics of the separate schema files
    in the single output
  - The input documents are changed as little as possible, so the output is as
    readable as the input
- Load schemas from:
  - The filesystem
  - From a Python package's data (without unpacking it to the filesystem)
  - Any type of URL by writing your own
    [UrlHandler](https://github.com/h4l/rnginline/blob/main/rnginline/urlhandlers.py)
- Command-line interface & Python API
- Test suite covering lots of edge cases, e.g. namespace handling
  - 100% line & branch code coverage

## Quickstart

Install with pip (or [pipx](https://pypa.github.io/pipx/) if you only need the
command-line program):

```console
$ pipx install rnginline
```

You can use it from the command line like this:

```console
$ rnginline my-nested-schema-root.rng flattened-output.rng
```

You can use it from Python like this:

```python
>>> import rnginline
>>> rnginline.inline('my-nested-schema-root.rng')
<lxml.etree.RelaxNG object at ...>
```

You can load a multi-file schema from a Python package's data like this:

```python
>>> import rnginline
>>> from rnginline.urlhandlers import pydata
>>> url = pydata.makeurl('rnginline.test',
...                      'data/testcases/external-ref-1/schema.rng')
>>> url
'pydata://rnginline.test/data/testcases/external-ref-1/schema.rng'
>>> rnginline.inline(url)
<lxml.etree.RelaxNG object at ...>
```

## Documentation

Documentation is available at http://rnginline.readthedocs.org/

## Motivation

`lxml` has good support for using RELAX NG schemas, but lacks support for
loading multi-file schemas from anywhere other than the filesystem. This is a
problem if you wish to bundle a multi-file schema with your Python
package/module. You'd have to depend on setuptools being available to use its
[resource extraction], or use one of the existing RELAX NG merging tools to
convert your schema into a single file.

[resource extraction]:
  https://pythonhosted.org/setuptools/pkg_resources.html#resource-extraction

## Existing RELAX NG flattening tools

The following projects didn't quite fit my needs, leading me to write rnginline.
They may work for you though.

- [rng2srng](http://kohsuke.org/relaxng/rng2srng/) — Implements full
  simplification, so the structure of the input schema will be lost
- [rng-incelim](http://ftp.davidashen.net/incelim/) — A similar project to this,
  implemented in XSLT. Unfortunately doesn't handle namespace declarations on
  `<include>` elements correctly. XSLT 1.0 doesn't support creating namespace
  nodes, so to fix this rng-incelim would have to resolve all QNames in the
  schema to NCNames with ns attributes, which would be undesirable for me.

## Developing

Instructions for developers working on this project are in
[DEVELOPING.md](https://github.com/h4l/rnginline/blob/main/DEVELOPING.md).


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/h4l/rnginline",
    "name": "rnginline",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "relaxng,inline,lxml,xml",
    "author": "Hal Blackburn",
    "author_email": "hwtb2@cam.ac.uk",
    "download_url": "https://files.pythonhosted.org/packages/6d/71/294bd361978a48ea5f16b1ccb5f18135ceec8c1ae8ce82eaeef47cbdee01/rnginline-1.0.0.tar.gz",
    "platform": null,
    "description": "# rnginline: Flatten multi-file RELAX NG schemas\n\n[![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/h4l/rnginline/main.yml?branch=main)](https://github.com/h4l/rnginline/actions)\n[![PyPI](https://img.shields.io/pypi/v/rnginline)](https://pypi.org/project/rnginline/)\n[![Read the Docs](https://img.shields.io/readthedocs/rnginline)](https://rnginline.readthedocs.io/en/latest/)\n\nrnginline is a Python library and command-line tool for loading multi-file RELAX\nNG schemas from arbitary URLs, and flattening them into a single RELAX NG\nschema.\n\n## Features\n\n- Convert multi-file RNG schemas into one file **without breaking or\n  restructuring the schemas**\n  - Great care is taken to maintain the semantics of the separate schema files\n    in the single output\n  - The input documents are changed as little as possible, so the output is as\n    readable as the input\n- Load schemas from:\n  - The filesystem\n  - From a Python package's data (without unpacking it to the filesystem)\n  - Any type of URL by writing your own\n    [UrlHandler](https://github.com/h4l/rnginline/blob/main/rnginline/urlhandlers.py)\n- Command-line interface & Python API\n- Test suite covering lots of edge cases, e.g. namespace handling\n  - 100% line & branch code coverage\n\n## Quickstart\n\nInstall with pip (or [pipx](https://pypa.github.io/pipx/) if you only need the\ncommand-line program):\n\n```console\n$ pipx install rnginline\n```\n\nYou can use it from the command line like this:\n\n```console\n$ rnginline my-nested-schema-root.rng flattened-output.rng\n```\n\nYou can use it from Python like this:\n\n```python\n>>> import rnginline\n>>> rnginline.inline('my-nested-schema-root.rng')\n<lxml.etree.RelaxNG object at ...>\n```\n\nYou can load a multi-file schema from a Python package's data like this:\n\n```python\n>>> import rnginline\n>>> from rnginline.urlhandlers import pydata\n>>> url = pydata.makeurl('rnginline.test',\n...                      'data/testcases/external-ref-1/schema.rng')\n>>> url\n'pydata://rnginline.test/data/testcases/external-ref-1/schema.rng'\n>>> rnginline.inline(url)\n<lxml.etree.RelaxNG object at ...>\n```\n\n## Documentation\n\nDocumentation is available at http://rnginline.readthedocs.org/\n\n## Motivation\n\n`lxml` has good support for using RELAX NG schemas, but lacks support for\nloading multi-file schemas from anywhere other than the filesystem. This is a\nproblem if you wish to bundle a multi-file schema with your Python\npackage/module. You'd have to depend on setuptools being available to use its\n[resource extraction], or use one of the existing RELAX NG merging tools to\nconvert your schema into a single file.\n\n[resource extraction]:\n  https://pythonhosted.org/setuptools/pkg_resources.html#resource-extraction\n\n## Existing RELAX NG flattening tools\n\nThe following projects didn't quite fit my needs, leading me to write rnginline.\nThey may work for you though.\n\n- [rng2srng](http://kohsuke.org/relaxng/rng2srng/) \u2014 Implements full\n  simplification, so the structure of the input schema will be lost\n- [rng-incelim](http://ftp.davidashen.net/incelim/) \u2014 A similar project to this,\n  implemented in XSLT. Unfortunately doesn't handle namespace declarations on\n  `<include>` elements correctly. XSLT 1.0 doesn't support creating namespace\n  nodes, so to fix this rng-incelim would have to resolve all QNames in the\n  schema to NCNames with ns attributes, which would be undesirable for me.\n\n## Developing\n\nInstructions for developers working on this project are in\n[DEVELOPING.md](https://github.com/h4l/rnginline/blob/main/DEVELOPING.md).\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Flatten multi-file RELAX NG schemas",
    "version": "1.0.0",
    "project_urls": {
        "Documentation": "https://rnginline.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/h4l/rnginline",
        "Repository": "https://github.com/h4l/rnginline"
    },
    "split_keywords": [
        "relaxng",
        "inline",
        "lxml",
        "xml"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2fa5ea5988d6540d74da85a8c3024213b768e5408598be68e548d10857bdd8f2",
                "md5": "9e4cec497d62981bd701afd6c00fce62",
                "sha256": "907307854e8c9d26639f2cdbf8e492a80ee8f69d1a6707e77ff4a4820cff3e13"
            },
            "downloads": -1,
            "filename": "rnginline-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e4cec497d62981bd701afd6c00fce62",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 85632,
            "upload_time": "2023-05-07T15:18:42",
            "upload_time_iso_8601": "2023-05-07T15:18:42.415706Z",
            "url": "https://files.pythonhosted.org/packages/2f/a5/ea5988d6540d74da85a8c3024213b768e5408598be68e548d10857bdd8f2/rnginline-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d71294bd361978a48ea5f16b1ccb5f18135ceec8c1ae8ce82eaeef47cbdee01",
                "md5": "9680e7576f3663c853e86d8ef0428e90",
                "sha256": "256ab3b3e3aa3b29c8016615806ad98ae882a8e6c08067baac1b740dc3f753a1"
            },
            "downloads": -1,
            "filename": "rnginline-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9680e7576f3663c853e86d8ef0428e90",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 50730,
            "upload_time": "2023-05-07T15:18:45",
            "upload_time_iso_8601": "2023-05-07T15:18:45.045592Z",
            "url": "https://files.pythonhosted.org/packages/6d/71/294bd361978a48ea5f16b1ccb5f18135ceec8c1ae8ce82eaeef47cbdee01/rnginline-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-07 15:18:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "h4l",
    "github_project": "rnginline",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "rnginline"
}
        
Elapsed time: 0.07817s