jsonix-schema-compiler
jsonix-schema-compiler copied to clipboard
Unable to generate json schema
I am brand new to using the schema compiler, and not very familiar with the xml schema notation. I ran the shiporder example, and got the expected results. I am trying to convert a large complex xml schema that uses the building block below.
Running the compiler using the command line below did not generate any files. Any guidance you can provide would be much appreciated.
Thanks. Peter
java -jar ./jsonix-schema-compiler-full-2.3.9.jar -generateJsonSchema -d mappings -logLevel DEBUG xml_test.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/1999/xhtml" xmlns:xml="http://www.w3.org/XML/1998/namespace" targetNamespace="http://www.w3.org/XML/1998/namespace" xml:lang="en"> <xs:attribute name="lang"> xs:simpleType <xs:union memberTypes="xs:language"> xs:simpleType <xs:restriction base="xs:string"> <xs:enumeration value=""/> </xs:restriction> </xs:simpleType> </xs:union> </xs:simpleType> </xs:attribute> <xs:attribute name="space"> xs:simpleType <xs:restriction base="xs:NCName"> <xs:enumeration value="default"/> <xs:enumeration value="preserve"/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="base" type="xs:anyURI"> </xs:attribute> <xs:attribute name="id" type="xs:ID"> </xs:attribute> <xs:attributeGroup name="specialAttrs"> <xs:attribute ref="xml:base"/> <xs:attribute ref="xml:lang"/> <xs:attribute ref="xml:space"/> <xs:attribute ref="xml:id"/> </xs:attributeGroup> </xs:schema>
You're not getting any output as there's nothing to generate. Your schema does not declare any complex types.
Try the following schema:
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
targetNamespace="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xml:lang="en">
<xs:attribute name="lang">
<xs:simpleType>
<xs:union memberTypes="xs:language">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=""/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="space">
<xs:simpleType>
<xs:restriction base="xs:NCName">
<xs:enumeration value="default"/>
<xs:enumeration value="preserve"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="base" type="xs:anyURI">
</xs:attribute>
<xs:attribute name="id" type="xs:ID">
</xs:attribute>
<xs:attributeGroup name="specialAttrs">
<xs:attribute ref="xml:base"/>
<xs:attribute ref="xml:lang"/>
<xs:attribute ref="xml:space"/>
<xs:attribute ref="xml:id"/>
</xs:attributeGroup>
<xs:complexType name="test">
<xs:attributeGroup ref="xml:specialAttrs"/>
</xs:complexType>
</xs:schema>
You should get org_w3_xml__1998_namespace.jsonschema
and org_w3_xml__1998_namespace.js
.
Thank you sir, much appreciated! I was wondering about that. I am now running into the problem with the xlink.xsd schema below.
I will continue debugging.
Peter
ppiela@ppiela-Inspiron-5577:~/jsonix$ java -jar ./jsonix-schema-compiler-full-2.3.9.jar -generateJsonSchema -d mappings -p xml -logLevel TRACE xlink.xsd [ERROR] Property "Title" is already defined. Use <jaxb:property> to resolve this conflict. line 143 of file:/home/ppiela/jsonix/xlink.xsd
[ERROR] The following location is relevant to the above error line 137 of file:/home/ppiela/jsonix/xlink.xsd
[ERROR] Property "Title" is already defined. Use <jaxb:property> to resolve this conflict. line 163 of file:/home/ppiela/jsonix/xlink.xsd
[ERROR] The following location is relevant to the above error line 154 of file:/home/ppiela/jsonix/xlink.xsd
[ERROR] org.hisrc.jsonix.execution.JsonixInvoker - The model is null, there was probably a problem parsing schemas.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" targetNamespace="http://www.w3.org/1999/xlink"> <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/> <xs:attribute name="type" type="xlink:typeType"/> <xs:simpleType name="typeType"> <xs:restriction base="xs:token"> <xs:enumeration value="simple"/> <xs:enumeration value="extended"/> <xs:enumeration value="title"/> <xs:enumeration value="resource"/> <xs:enumeration value="locator"/> <xs:enumeration value="arc"/> </xs:restriction> </xs:simpleType> <xs:attribute name="href" type="xlink:hrefType"/> <xs:simpleType name="hrefType"> <xs:restriction base="xs:anyURI"/> </xs:simpleType> <xs:attribute name="role" type="xlink:roleType"/> <xs:simpleType name="roleType"> <xs:restriction base="xs:anyURI"> <xs:minLength value="1"/> </xs:restriction> </xs:simpleType> <xs:attribute name="arcrole" type="xlink:arcroleType"/> <xs:simpleType name="arcroleType"> <xs:restriction base="xs:anyURI"> <xs:minLength value="1"/> </xs:restriction> </xs:simpleType> <xs:attribute name="title" type="xlink:titleAttrType"/> <xs:simpleType name="titleAttrType"> <xs:restriction base="xs:string"/> </xs:simpleType> <xs:attribute name="show" type="xlink:showType"/> <xs:simpleType name="showType"> <xs:restriction base="xs:token"> <xs:enumeration value="new"/> <xs:enumeration value="replace"/> <xs:enumeration value="embed"/> <xs:enumeration value="other"/> <xs:enumeration value="none"/> </xs:restriction> </xs:simpleType> <xs:attribute name="actuate" type="xlink:actuateType"/> <xs:simpleType name="actuateType"> <xs:restriction base="xs:token"> <xs:enumeration value="onLoad"/> <xs:enumeration value="onRequest"/> <xs:enumeration value="other"/> <xs:enumeration value="none"/> </xs:restriction> </xs:simpleType> <xs:attribute name="label" type="xlink:labelType"/> <xs:simpleType name="labelType"> <xs:restriction base="xs:NCName"/> </xs:simpleType> <xs:attribute name="from" type="xlink:fromType"/> <xs:simpleType name="fromType"> <xs:restriction base="xs:NCName"/> </xs:simpleType> <xs:attribute name="to" type="xlink:toType"/> <xs:simpleType name="toType"> <xs:restriction base="xs:NCName"/> </xs:simpleType> <xs:attributeGroup name="simpleAttrs"> <xs:attribute ref="xlink:type" fixed="simple"/> <xs:attribute ref="xlink:href"/> <xs:attribute ref="xlink:role"/> <xs:attribute ref="xlink:arcrole"/> <xs:attribute ref="xlink:title"/> <xs:attribute ref="xlink:show"/> <xs:attribute ref="xlink:actuate"/> </xs:attributeGroup> <xs:group name="simpleModel"> xs:sequence <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:group> <xs:complexType name="simple" mixed="true"> <xs:group ref="xlink:simpleModel"/> <xs:attributeGroup ref="xlink:simpleAttrs"/> </xs:complexType> <xs:attributeGroup name="extendedAttrs"> <xs:attribute ref="xlink:type" use="required" fixed="extended"/> <xs:attribute ref="xlink:role"/> <xs:attribute ref="xlink:title"/> </xs:attributeGroup> <xs:group name="extendedModel"> xs:choice <xs:element ref="xlink:title"/> <xs:element ref="xlink:resource"/> <xs:element ref="xlink:locator"/> <xs:element ref="xlink:arc"/> </xs:choice> </xs:group> <xs:complexType name="extended"> <xs:group ref="xlink:extendedModel" minOccurs="0" maxOccurs="unbounded"/> <xs:attributeGroup ref="xlink:extendedAttrs"/> </xs:complexType> <xs:element name="title" type="xlink:titleEltType" abstract="true"/> <xs:attributeGroup name="titleAttrs"> <xs:attribute ref="xlink:type" use="required" fixed="title"/> <xs:attribute ref="xml:lang"> </xs:attribute> </xs:attributeGroup> <xs:group name="titleModel"> xs:sequence <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:group> <xs:complexType name="titleEltType" mixed="true"> <xs:group ref="xlink:titleModel"/> <xs:attributeGroup ref="xlink:titleAttrs"/> </xs:complexType> <xs:element name="resource" type="xlink:resourceType" abstract="true"/> <xs:attributeGroup name="resourceAttrs"> <xs:attribute ref="xlink:type" use="required" fixed="resource"/> <xs:attribute ref="xlink:role"/> <xs:attribute ref="xlink:title"/> <xs:attribute ref="xlink:label"/> </xs:attributeGroup> <xs:group name="resourceModel"> xs:sequence <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:group> <xs:complexType name="resourceType" mixed="true"> <xs:group ref="xlink:resourceModel"/> <xs:attributeGroup ref="xlink:resourceAttrs"/> </xs:complexType> <xs:element name="locator" type="xlink:locatorType" abstract="true"/> <xs:attributeGroup name="locatorAttrs"> <xs:attribute ref="xlink:type" use="required" fixed="locator"/> <xs:attribute ref="xlink:href" use="required"/> <xs:attribute ref="xlink:role"/> <xs:attribute ref="xlink:title"/> <xs:attribute ref="xlink:label"> </xs:attribute> </xs:attributeGroup> <xs:group name="locatorModel"> xs:sequence <xs:element ref="xlink:title" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:group> <xs:complexType name="locatorType"> <xs:group ref="xlink:locatorModel"/> <xs:attributeGroup ref="xlink:locatorAttrs"/> </xs:complexType> <xs:element name="arc" type="xlink:arcType" abstract="true"/> <xs:attributeGroup name="arcAttrs"> <xs:attribute ref="xlink:type" use="required" fixed="arc"/> <xs:attribute ref="xlink:arcrole"/> <xs:attribute ref="xlink:title"/> <xs:attribute ref="xlink:show"/> <xs:attribute ref="xlink:actuate"/> <xs:attribute ref="xlink:from"/> <xs:attribute ref="xlink:to"> </xs:attribute> </xs:attributeGroup> <xs:group name="arcModel"> xs:sequence <xs:element ref="xlink:title" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:group> <xs:complexType name="arcType"> <xs:group ref="xlink:arcModel"/> <xs:attributeGroup ref="xlink:arcAttrs"/> </xs:complexType> </xs:schema>
On the full schema that I am trying to process I get the following:
[WARNING] Simple type "DocumentBase" was not mapped to Enum due to EnumMemberSizeCap limit. Facets count: 600, current limit: 256. You can use customization attribute "typesafeEnumMaxMembers" to extend the limit.
You'll need to use bindings to customize code generation.
See this one for XLink:
https://github.com/highsource/w3c-schemas/blob/master/xlink/1999/src/main/resources/xlink-v_1_0.xjb
For typesafeEnumMaxMembers
see:
https://stackoverflow.com/questions/12779046/create-java-classes-with-jaxb
If you need support, consider sending me a PR with your schema compilation project here:
https://github.com/highsource/jsonix-support
Under s/someletter
. See https://github.com/highsource/jsonix-support/tree/master/a/amzn for example.
Thank you again for the information! I got through my initial issues, and am now working on the full schema. My eventual goal is to be able to use the json schema with the brutusin:json-forms package to browse, edit, and validate schema instances. The brutusin component will require some enhancement, as it does not provide complete support for the json-schema specification.
I will not hesitate to open support cases at the address you provided