Skip to main content

Python package providing schema files commonly needed in GAMS projects, along with utilities to interact with the catalog.

Project description

gams-xml-catalog

A Python package that provides an XML catalog containing schema files commonly needed in GAMS projects.

Starting with lxml version 6, the underlying libxml2 library disables fetching resources from the internet by default for security reasons. This library solves that problem by providing local copies of frequently used XML schemas and resources, making them accessible through the standard XML Catalog mechanism (https://xmlcatalogs.org/).

Additionally, it provides a resolve_uri_to_path() function to retrieve the local file path for any catalog resource. In most cases, using the default catalog mechanism is preferred—simply call gams_xml_catalog.activate_catalog() and let tools like lxml or saxonche handle URI resolution automatically.

Installation

Install the package from PyPI using pip:

pip install gams-xml-catalog

Usage

To use the catalog, simply import and activate it:

import gams_xml_catalog
gams_xml_catalog.activate_catalog()

This temporarily adds the catalog path to the XML_CATALOG_FILES environment variable, enabling lxml and other XML-aware tools to use local copies instead of fetching resources from the internet. Any tool with XML Catalog support will automatically benefit from this setup.

Direct URI to Path Resolution

For non-XML formats (such as RelaxNG Compact) or when you need to resolve URIs without triggering XML parsing, use the resolve_uri_to_path() function:

import gams_xml_catalog 

# Resolve a RelaxNG Compact file (no XML parsing)
path = gams_xml_catalog.resolve_uri_to_path("http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rnc")
print(f"Local file: {path}")
# Output: /path/to/catalog/tei/p5/relaxng/tei_all.rnc

# For advanced use cases, create a CatalogResolver instance:
from gams_xml_catalog import CatalogResolver, get_catalog_path

resolver = CatalogResolver(get_catalog_path())
path = resolver.resolve("http://purl.org/dc/elements/1.1/")  # auto-detect URI or system ID
path = resolver.resolve_uri("http://www.w3.org/1999/xlink")  # resolve as URI
path = resolver.resolve_system("http://www.tei-c.org/release/xml/tei/custom/schema/xsd/tei_all.xsd")  # resolve as system ID

This approach is useful for:

  • Processing non-XML formats like RelaxNG Compact (.rnc)
  • Pre-resolving URIs for tools without XML Catalog support
  • Building schema dependency graphs without triggering parse errors

Contributing

The Github repository is ment to be a read only mirror of the work repository hosted on our institutional private Github server. You can use the bug tracker on Github, but everything else should happen in the Zimlab Github repo.

License

The package code is distributed under the MIT license (see LICENSE for details). The XML schemas and resources included in the catalog are primarily in the public domain. For some resources, explicit licensing information was not available.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gams_xml_catalog-0.6.8.tar.gz (5.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gams_xml_catalog-0.6.8-py3-none-any.whl (5.8 MB view details)

Uploaded Python 3

File details

Details for the file gams_xml_catalog-0.6.8.tar.gz.

File metadata

  • Download URL: gams_xml_catalog-0.6.8.tar.gz
  • Upload date:
  • Size: 5.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gams_xml_catalog-0.6.8.tar.gz
Algorithm Hash digest
SHA256 3ec6ad617d9987e8a158e5044c222ddfc64f178fe5c3bb1f46867749d85db68d
MD5 ea0e30cb890b12fbbd63308d2722c5e3
BLAKE2b-256 aec8c99da79c44993b58cd22f8c6518fa6dd6ae2590611a299552fc72d5ad0e8

See more details on using hashes here.

File details

Details for the file gams_xml_catalog-0.6.8-py3-none-any.whl.

File metadata

  • Download URL: gams_xml_catalog-0.6.8-py3-none-any.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gams_xml_catalog-0.6.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4372ad72763d37142ebdb5e5b449737d5db90b1c513880daec1a4b2ed30b721b
MD5 87395b74b04e79d1701ffbe65d36b8bf
BLAKE2b-256 b36d482b51abf3727384076e8eaf47dadf9781e24a887596f8bd01b9588dcab9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page