Python script that converts XSD files into JSON Schema.
For example, transforming:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="example" type="xs:string" nillable="true" />
</xs:schema>
Into:
{
"properties": {
"example": {
"type": "string"
}
},
"required": [
"example"
],
"$schema": "http://json-schema.org/schema#"
}
Output JSON schema to stdout.
xsdtojson [PATH TO XSD FILE] --pretty
Output JSON schema to file
xsdtojson [PATH TO XSD FILE] > [PATH TO JSON OUTPUT FILE]
from xsdtojson import xsd_to_json_schema
json_schema = xsd_to_json_schema([PATH TO XSD FILE])
- Convert XSD data types to JSON Schema types. See generateRS for possible mappings.
- Add JSON-LD URI to schema - potential refs:
- Write tests. Ideally these will:
- Build a JSON schema from XSD
- Create & validate JSON-LD record
- Use online JSON-LD=>RDF converter, and validated JSON_LD against original XSD.
- Convert more XSD sources: