Trading Networks 10.7 | Administering and Monitoring B2B Transactions | Service Development Help | Working with Document Types | Creating an IS Document Type | Registering Document Types with Their Schema Types
 
Registering Document Types with Their Schema Types
When creating IS document types from XML schema definitions, you can have Integration Server register the IS document types with the XML schema types. To register IS document types, you must select the Generate document types for complex types and the Register document types with schema type options. By registering the IS document types, you establish a one-to-one mapping between each generated IS document type and its corresponding complex type within the XML schema definition.
Note:
When creating a web service descriptor from a WSDL, Integration Server registers each document type that it creates with the associated schema type defined in the WSDL.
It is important to register IS document types when the XML schema definition uses derived types so that Integration Server can later perform data conversion. That is so that Integration Server can convert data that conforms to the IS document types and the XML schema definition from a document (IData object) to XML, and vice versa. It is also important so that Integration Server can validate documents (IData objects) that use derived types. For more information about derived types and derived document types, see Derived Types and IS Document Types and *doctype Fields in IS Document Types and Document Fields.
The rest of this section illustrates what happens when Integration Server registers IS document types with their XML schema types and how the registration is used during data conversion. The following shows a portion of an XML schema definition that is used for the illustration.
<xsd:element name="purchaseOrder">
<xsd:sequence>
<xsd:element name="id" type="xsd:string"/>
<xsd:element name="invoiceAddress" type="order:Address">
</xsd:sequence>
</xsd:element>
<xsd:complexType name="Address">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="USAddress">
<xsd:complexContent>
<xsd:extension base="order:Address">
<xsd:sequence>
<xsd:element name="state"/>
<xsd:element name="zip"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
When you create IS document types from the above XML schema definition, selecting the Generate document types for complex types and the Register document types with schema type options, Integration Server:
*Creates an IS document type for the base Address complex type and another for the derived USAddress complex type.
*Adds a *doctype field to IS document types created for the base Address complex type and the derived USAddress complex type.
*Registers the Address complex type with the IS document type it generates for the Address complex type.
*Registers the USAddress complex type with the derived IS document type it generates for the derived USAddress complex type. For example, this might establish a mapping between the complex type order:USAddress and the IS document type docTypeRef_order_USAddress.
Because the IS document types were registered with the XML schema types, Integration Server can later:
*Convert XML data based on the schema to a document (IData object) and validate the document
When an element in an XML instance is based on a derived type, the XML uses the xsi:type attribute to identify the derived type for the element. When the IS document type associated with derived type is registered, Integration Server can locate the correct IS document type to use for the conversion, as well as set the *doctype field to indicate the IS document type that defines the format in the resulting document (IData object).
For example, if Integration Server converts an XML document that uses the USAddress complex type, when parsing the XML, Integration Server finds the <invoiceAddress xsi:type=”order:USAddress” element. Integration Server uses the value of the xsi:type attribute, that is order:USAddress, and looks up the registration to determine the corresponding IS document type. After Integration Server determines the IS document type, it can then do the conversion using the IS document type that corresponds to order:USAddress.
During the conversion, Integration Server sets the *doctype field to the fully-qualified name of the IS document type it found in the registration. As a result, when Integration Server validates the IData object, it determines the correct IS document type to use for validation by using the value in the *doctype field.
Note:
When converting XML to an IData object, if Integration Server encounters an <xsi:type> attribute in a simple type, Integration Server ignores it. No *doctype field is added.
*Convert Document fields based on the IS document types to XML
When a Document field is based on a derived document type, the Document field contains a *doctype field to identify the name of the derived document type that defines the Document field’s structure. Integration Server can look up the document type name in the registration to determine the corresponding Qualified Name (QName) of the complex type in the schema. Integration Server uses this QName to populate the xsi:type attribute that it places in the XML it is generating.
For example, if Integration Server converts a Document field containing a *doctype field that has a value that is the fully-qualified name of the IS document type, “docType_Ref_order_USAddress”, it uses the value of the *doctype field and looks up the registration to determine the corresponding Qualified Name (QName), which it uses to populate the xsi:type attribute in the resulting XML.