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.3.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.3-py3-none-any.whl (5.8 MB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gams_xml_catalog-0.6.3.tar.gz
Algorithm Hash digest
SHA256 5f6b4eb53698d68deb4f45be144402da82be535f0ec2f34a0c02c5cf789a95f1
MD5 8c7a4822119ba3baea07ff80d081daef
BLAKE2b-256 d0e8246b668b05ec73dcc7308d5da9341c50fe4c1f8dd5f24287f8934b87ff33

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gams_xml_catalog-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cea16df0df09d99d3b1978b8357b784a596b40cc6cb7d87ca041c65d884d0db6
MD5 fe244fd43ff4a0405c4ed7a2d9d33cab
BLAKE2b-256 7efc2ac829168d30c81df318c502d56edc84e8a4f3344e958690c8f4e3090d06

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