Skip to content

Generating XML Schema Type Names

Alexey Valikov edited this page Apr 11, 2015 · 2 revisions

Generating XML Schema Type Names

Jsonix Schema Compiler adds type names from the original XML Schema to the generated mappings.

For instance, consider the following XML Schema fragment:

<xs:complexType name="My_Type">
	<xs:sequence>
		...
	</xs:sequence>
</xs:complexType>

This will generate a mapping like:

{
        localName: 'MyType',
        typeName: 'My_Type',
        propertyInfos: [ ... ]
}

Type names are considered to be qualified, i.e. consisting of a namespace and a local part.

If the local part of the type name equals the local name of the type itself and the namespace matches the target namespace of the mapping, type name will be omitted. In this case Jsonix will construct the type name based on the target namespace of the module and the local name of the type, so it would have resulten in the same qualified type name. To reduce module size, the type name is omitted. This is the default case.

If the local part of the type name does not equal the local name of the type but the namespace matches the target namespace of the mapping, Jsonix Schema Compiler generates typeName: '<localPart>' property, with the local part of the type name as string. Jsonix will combine the target namespace of the mapping with the string type name. This is the case in the example above.

If the namespace of the type name does not match the target namespace of the mapping, Jsonix Schema Compiler generates the qualified type name ({ localPart: '<localPart>', namespaceURI: '<namespaceURI>' }).

If the originating type does not have a name (i.e. it is a anonymous type), Jsonix will generate typeName: null.

Clone this wiki locally