Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support XML Schema Definition Language (XSD) import #153

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
306 changes: 158 additions & 148 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ click-default-group = "^1.2.4"
linkml-runtime = "^1.7.2"
duckdb = "^0.10.1"
numpy = "<2.0"
lxml = "^5.3.0"

[tool.poetry.dev-dependencies]
pytest = ">=7.1.1"
Expand All @@ -62,7 +63,7 @@ sphinx-click = ">=3.1.0"
sphinxcontrib-mermaid = ">=0.9.2"
myst-parser = "*"
jupyter = ">=1.0.0"
lxml = ">=4.9.1"
lxml-stubs = "^0.5.1"

[tool.poetry.group.llm.dependencies]
llm = ">=0.12"
Expand Down
18 changes: 18 additions & 0 deletions schema_automator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from schema_automator.importers.rdfs_import_engine import RdfsImportEngine
from schema_automator.importers.sql_import_engine import SqlImportEngine
from schema_automator.importers.tabular_import_engine import TableImportEngine
from schema_automator.importers.xsd_import_engine import XsdImportEngine
from schema_automator.utils.schemautils import write_schema
from schema_automator import __version__

Expand Down Expand Up @@ -497,6 +498,23 @@ def import_rdfs(rdfsfile, output, metamodel_mappings, **args):
schema = sie.convert(rdfsfile, **args)
write_schema(schema, output)

@main.command()
@click.argument('xsd')
@output_option
@schema_name_option
@click.option('--output', '-o', help="Path to saved yaml schema")
def import_xsd(xsd: str, output: str, **kwargs):
"""
Import an XML Schema Definition Language (XSD) schema to LinkML

Example:

schemauto import-xsd schema.xml -o prov.yaml
"""
engine = XsdImportEngine()
schema = engine.convert(xsd, **kwargs)
write_schema(schema, output)

@main.command()
@click.argument('rdffile')
@output_option
Expand Down
10 changes: 10 additions & 0 deletions schema_automator/importers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
from schema_automator.importers.dosdp_import_engine import DOSDPImportEngine
from schema_automator.importers.frictionless_import_engine import FrictionlessImportEngine
from schema_automator.importers.cadsr_import_engine import CADSRImportEngine
from schema_automator.importers.xsd_import_engine import XsdImportEngine

__all__ = [
'JsonSchemaImportEngine',
'OwlImportEngine',
'DOSDPImportEngine',
'FrictionlessImportEngine',
'CADSRImportEngine',
'XsdImportEngine'
]
Loading