{"id":27392,"library":"shexjsg","title":"ShExJSG","description":"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.","status":"active","version":"0.8.2","language":"python","source_language":"en","source_url":"https://github.com/hsolbrig/ShExJSG","tags":["shacl","shex","rdf","ast","schema"],"install":[{"cmd":"pip install shexjsg","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for JSON Schema grammar","package":"pyjsg","optional":false},{"reason":"Used for RDF handling and ShEx validation (v5 or v6)","package":"rdflib","optional":false},{"reason":"Required for parsing with Antlr4","package":"antlr4-python3-runtime","optional":false}],"imports":[{"note":"ShExJ is the primary schema class; direct import is incorrect.","wrong":"import shexjsg","symbol":"ShExJ","correct":"from shexjsg import ShExJ"},{"note":"Schema is located in the schema submodule.","wrong":"from shexjsg import Schema","symbol":"Schema","correct":"from shexjsg.schema import Schema"}],"quickstart":{"code":"from shexjsg import ShExJ\nfrom rdflib import Graph\nimport json\n\n# Create a simple schema\nschema_json = '''{\n  \"@context\": \"http://www.w3.org/ns/shex.jsonld\",\n  \"type\": \"Schema\",\n  \"shapes\": [\n    {\n      \"id\": \"http://example.org/FooShape\",\n      \"type\": \"Shape\",\n      \"expression\": {\n        \"type\": \"TripleConstraint\",\n        \"predicate\": \"http://example.org/p\",\n        \"valueExpr\": {\n          \"type\": \"NodeConstraint\",\n          \"datatype\": \"http://www.w3.org/2001/XMLSchema#string\"\n        }\n      }\n    }\n  ]\n}'''\n\n# Parse and load schema\nschema = ShExJ()\nschema.loads(schema_json)\nprint('Schema loaded successfully')\nprint(json.dumps(schema.as_dict(), indent=2))","lang":"python","description":"Parses a ShEx schema from a JSON string using ShExJSG."},"warnings":[{"fix":"Upgrade rdflib to >=5.0.0 or pin shexjsg to 0.7.1.","message":"Version 0.8.0 changed rdflib support from v4 to v5/v6. Code using rdflib 4 may break.","severity":"breaking","affected_versions":"<0.8.0"},{"fix":"Install/upgrade pyjsg: pip install pyjsg --upgrade","message":"ShExJSG depends on PyJSG, which itself generates code. Ensure PyJSG is installed and up-to-date to avoid import errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: pip install shexjsg","cause":"The package shexjsg is not installed.","error":"ModuleNotFoundError: No module named 'shexjsg'"},{"fix":"Use: from shexjsg import ShExJ","cause":"Incorrect import path; ShExJ is not a direct attribute.","error":"AttributeError: module 'shexjsg' has no attribute 'ShExJ'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}