Registry / serialization / shexjsg

shexjsg

JSON →
library0.8.2pypypiunverified

ShExJSG is a Python library that provides an abstract syntax tree (AST) for the ShEx 2.0 schema language, built on PyJSG and Antlr. It is used for parsing, validating, and generating ShEx schemas. Current version is 0.8.2, with a history of adaptation to newer rdflib and Python versions.

pip install shexjsg
INSTALL
IMPORT
SIG · SHEXJSG
S
shexjsg
serializationpythonv0.8.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ShExJ
from ShExJSG import ShExJ
from shexjsg import ShExJ

Parses a ShEx schema from a JSON string using ShExJSG.

from shexjsg import ShExJ from rdflib import Graph import json # Create a simple schema schema_json = '''{ "@context": "http://www.w3.org/ns/shex.jsonld", "type": "Schema", "shapes": [ { "id": "http://example.org/FooShape", "type": "Shape", "expression": { "type": "TripleConstraint", "predicate": "http://example.org/p", "valueExpr": { "type": "NodeConstraint", "datatype": "http://www.w3.org/2001/XMLSchema#string" } } } ] }''' # Parse and load schema schema = ShExJ() schema.loads(schema_json) print('Schema loaded successfully') print(json.dumps(schema.as_dict(), indent=2))
Debug
Known issues
breakingVersion 0.8.0 changed rdflib support from v4 to v5/v6. Code using rdflib 4 may break.
fix
Upgrade rdflib to >=5.0.0 or pin shexjsg to 0.7.1.
affects: <0.8.0
gotchaShExJSG depends on PyJSG, which itself generates code. Ensure PyJSG is installed and up-to-date to avoid import errors.
fix
Install/upgrade pyjsg: pip install pyjsg --upgrade
affects: all
Upgrade
Version history
0.8.2latest on PyPI · released Apr 14, 2022
Audit
Dependencies
pyjsgrequiredCore dependency for JSON Schema grammar
rdflibrequiredUsed for RDF handling and ShEx validation (v5 or v6)
antlr4-python3-runtimerequiredRequired for parsing with Antlr4
Agent activity
5 hits · last 30 days
node
4
Resources
shexjsg — pip install shexjsg · libregistry