highsource/jsonix-schema-compiler

Generating JSON schema from XSD using CLI

Clemens-U opened this issue · 4 comments

Hi!

I tried to generate a JSON schema from a sample XSD (shiporder.xsd) but Jsonix didn't produce any output. I used the command-line in the following way:
java -jar jsonix-schema-compiler-full-2.3.6.jar -generateJsonSchema -logLevel DEBUG shiporder.xsd

And here is the input XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="shiporder">
    <xs:annotation>
        <xs:documentation>Shipping address</xs:documentation>
    </xs:annotation>     
    <xs:complexType>
      <xs:sequence>
        <xs:element name="orderperson" type="xs:string"/>
        <xs:element name="shipto">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="name" type="xs:string"/>
              <xs:element name="address" type="xs:string"/>
              <xs:element name="city" type="xs:string"/>
              <xs:element name="country" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>       
      </xs:element>
        <xs:element maxOccurs="unbounded" name="item">
          <xs:complexType>
            <xs:sequence>
        <xs:element name="title" type="xs:string"/>
        <xs:element minOccurs="0" name="note" type="xs:string"/>
        <xs:element name="quantity" type="xs:positiveInteger"/>
        <xs:element name="price" type="xs:decimal">
            <xs:annotation>
                <xs:documentation>Price of shipment</xs:documentation>
            </xs:annotation>
        </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
      <xs:attribute name="orderid" type="xs:string" use="required"/>
  </xs:complexType>
</xs:element>

</xs:schema>

All I get is:

[DEBUG] org.hisrc.jsonix.configuration.ModulesConfiguration - Assigning id [generated] to the mapping with name [generated].
[DEBUG] org.hisrc.jsonix.configuration.MappingConfiguration - Package [generated] will be mapped by the mapping [generated].
[DEBUG] org.hisrc.jsonix.configuration.MappingConfiguration - Mapping [generated] will use "" as the target namespace as it is the most used element namespace URI in the package [generated].
[DEBUG] org.hisrc.jsonix.configuration.MappingConfiguration - Mapping [generated] will use "" as it is the most used attribute namespace URI in the package [generated].

But no JSON schema files are generated. Am I missing something? Any help is much appreciated :)

Kind regards
Clemens

I'll check and report. This should work.

Hm, I'm not getting this.

Exactly this command:

java -jar jsonix-schema-compiler-full-2.3.6.jar -generateJsonSchema -logLevel DEBUG shiporder.xsd

Produces generated.js and generated.jsonschema files for me. And exactly the same log output as you have.

I've just created a small support project for this:

https://github.com/highsource/jsonix-support/tree/master/s/shiporder

After npm install which just downloads the jsonix-schema-compiler, you can execute the following command:

java -jar node_modules/jsonix-schema-compiler/lib/jsonix-schema-compiler-full.jar -generateJsonSchema -d mappings -b bindings -p ShipOrder -logLevel DEBUG schemas

This produces ShipOrder.js and ShipOrder.jsonschema in mappings:

And that's all pretty vanilla, no fiddling on my side. I'm not quite sure what we're missing here, no idea why it doesn't work for you, can't really reproduce.

Hi highsource,

thank you for taking a look at this. This issue has been resolved now. The schema generation did actually work right from the beginning. I was just confused by the messages and did not check the real output folder for the generated files. I thought if there are those messages and no information that any output has been generated something must be wrong... Maybe add some output string including the path to the output files?

Thanks a lot again!

Sure, why not. Please file an issue, that's easy to fix.

On Mon, Aug 31, 2015 at 10:39 AM, Clemens Uhlenhut <notifications@github.com

wrote:

Closed #47
#47.


Reply to this email directly or view it on GitHub
#47 (comment)
.