IBM Support

How to specify custom attribute details in XSD

Troubleshooting


Problem

The XSD Generator script does not handle custom attributes.

Symptom

If an attribute is included in the input XML that does not come from the database (i.e. Order/Extn/@ExtnStatus), then the attribute details for type and size are defaulted to String of size 100. In the case of Order/Extn/@ExtnStatus, the datatype is defined as String of size 40.

Need a way to specify the type and size of the field so that it is specified correctly in the generated XSD.

Steps to reproduce:
1. Copy INSTALL_DIR/xapidocs/api_javadocs/XML/YFS_getOrderDetails_output.xml to INSTALL_DIR/xapidocs/extn/input/custom_YFS_getOrderDetails_output.xml

2. Update this file to contain a custom attribute, say Order/Extn/@ExtnStatus

3. Run xsd generator. Sample command - sci_ant.sh -Dxsdgen.use.targetnamespace=Y -Dxsdgen.use.datatypeimport=Y -f xsdGenerator.xml generate

Refer 'Resolving the problem' section for solution.

Diagnosing The Problem

The generated XSD specifies attribute Order/Extn@ExtnStatus as String of size 100, which is incorrect

Resolving The Problem

Add datatype for extended attribute in copied custom_YFS_getOrderDetails_output.xml as shown in example below. Note that the datatype Status is defined as Char 40 in YFSDataTypes.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--getOrderDetail Output XML-->
<Order OrderHeaderKey="" ... any other required attributes >
<Extn ExtnStatus="" >
<yfc:doc>
<Attributes>
<Attribute DataType="Status" Name="ExtnStatus"/>
</Attributes>
</yfc:doc>
</Extn>
</Order>

Sample lines from generated XSD showing correct type definition:


</xsd:element>
<xsd:complexType name="OrderXSDType">
<xsd:attribute name="ExtnStatus" type="yfctype:Status" use="optional"/>
</xsd:complexType>
</xsd:schema>

[{"Product":{"code":"SS6PEW","label":"IBM Sterling Order Management"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Extensions","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.2.1;9.2;9.1;9.0","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Document Information

Modified date:
10 May 2022

UID

swg21663288