highsource/jsonix-schema-compiler

sequence element from my XSD schema was generated improperly.

Opened this issue · 3 comments

Hi!

I tried to generate a JSON schema from a sample XSD. All elements were generated successfully to json schema except one element from my XSD schema was generated improperly.

And here is the element copied from input XSD:

<xs:element name="CONTENT_STATUS_HISTORY">
	<xs:annotation>
		<xs:documentation>Use this element for listing the document history</xs:documentation>
	</xs:annotation>
	<xs:complexType>
		<xs:sequence maxOccurs="unbounded">
			<xs:element name="CONTENT_STATUS" type="TYPE_CONTENT_STATUS_STRUCT"/>
			<xs:element name="SUBMISSION_NUMBER" type="submissionnumberType">
			<xs:annotation>
				<xs:documentation>Submission number for the given Status type</xs:documentation>
			</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
</xs:element>

+++++++ See the generated jsonschema below ++++++
I do not know why
jsonschema_issues.txt
name: 'contentstatusAndSUBMISSIONNUMBER',

===================================================================
													
	localName: 'GHSTS.DOCUMENTS.DOCUMENT.DOCUMENTGENERIC.CONTENTSTATUSHISTORY',
        typeName: null,
        propertyInfos: [{
            name: 'contentstatusAndSUBMISSIONNUMBER',
            required: true,
            minOccurs: 2,
            collection: true,
            elementTypeInfos: [{
                elementName: 'CONTENT_STATUS',
                typeInfo: '.TYPECONTENTSTATUSSTRUCT'
              }, {
                elementName: 'SUBMISSION_NUMBER'
              }],
            type: 'elements'
          }]
      }
=================================================================================================


"GHSTS.DOCUMENTS.DOCUMENT.DOCUMENTGENERIC.CONTENTSTATUSHISTORY":{
            "type":"object",
            "title":"GHSTS.DOCUMENTS.DOCUMENT.DOCUMENTGENERIC.CONTENTSTATUSHISTORY",
            "required":[
                "contentstatusAndSUBMISSIONNUMBER"
            ],
            "properties":{
                "contentstatusAndSUBMISSIONNUMBER":{
                    "title":"contentstatusAndSUBMISSIONNUMBER",
                    "allOf":[
                        {
                            "type":"array",
                            "items":{
                                "anyOf":[
                                    {
                                        "anyOf":[
                                            {
                                                "$ref":"#/definitions/TYPECONTENTSTATUSSTRUCT"
                                            }
                                        ],
                                        "elementName":{
                                            "localPart":"CONTENT_STATUS",
                                            "namespaceURI":"http://www.oecd.org/GHSTS"
                                        }
                                    },
                                    {
                                        "anyOf":[
                                            {
                                                "$ref":"http://www.jsonix.org/jsonschemas/w3c/2001/XMLSchema.jsonschema#/definitions/string"
                                            }
                                        ],
                                        "elementName":{
                                            "localPart":"SUBMISSION_NUMBER",
                                            "namespaceURI":"http://www.oecd.org/GHSTS"
                                        }
                                    }
                                ]
                            },
                            "minItems":2
                        }
                    ],
                    "propertyType":"elements"
                }
            },
            "typeType":"classInfo",
            "propertiesOrder":[
                "contentstatusAndSUBMISSIONNUMBER"
            ]
        },

Why do you say it is generated improperly?

Why does it generate a name like this : contentstatusAndSUBMISSIONNUMBER and propertyorder like this contentstatusAndSUBMISSIONNUMBER
propertyInfos: [{
name: 'contentstatusAndSUBMISSIONNUMBER',
required: true,
minOccurs: 2,
collection: true,
elementTypeInfos: [{
elementName: 'CONTENT_STATUS',
typeInfo: '.TYPECONTENTSTATUSSTRUCT'
}, {
elementName: 'SUBMISSION_NUMBER'
}],
type: 'elements'
}]

Because you have an unbounded sequence with two elements. This results in a heterogeneous collection which may contain items of both elements. This is the only way to adequately represent your XML Schema.

What would you want to be generated?