jsonix-schema-compiler icon indicating copy to clipboard operation
jsonix-schema-compiler copied to clipboard

sequence element from my XSD schema was generated improperly.

Open tuhai63 opened this issue 8 years ago • 3 comments
trafficstars

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"
            ]
        },

tuhai63 avatar Nov 29 '16 16:11 tuhai63

Why do you say it is generated improperly?

highsource avatar Dec 01 '16 09:12 highsource

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' }]

tuhai63 avatar Dec 01 '16 13:12 tuhai63

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?

highsource avatar Dec 01 '16 14:12 highsource