Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 11 Business Object Model Mappings to XML Schema : Import Mappings - XSD to Business Object Model

Import Mappings - XSD to Business Object Model
Importing XML Schema Files describes how an XML schema document (XSD) can be imported into TIBCO Business Studio to create a Business Object Model. This section describes the mappings between the original XSD constructs and the resulting Business Object Model constructs.
In addition to creating UML elements in the Business Object Model, the original XSD information is also stored internally as stereotypes defined within a custom UML profile. This information is used if the Business Object Model originating from an XML schema import is re-exported as XSD so that the exported schema can be reconstructed to be logically equivalent to the original without loss of information (see Export Mappings). Note however, that this information exists only until the user makes a change to the model of the newly created Business Object Model. At this point the user will be presented with the following dialog:
Clicking OK will remove the profile containing the original XSD information. Subsequent export of this Business Object Model to XML Schema will follow the mappings for a "user-defined" Business Object Model outlined in Export Mappings.
Target Namespace
The schema ExampleSchema.xsd with the following namespace information:
 
<schema xmlns=http://www.w3.org/2001/XMLSchema targetNamespace="http://www.example.org/ExampleSchema"
 mlns:tns="http://www.example.org/ExampleSchema" elementFormDefault="qualified">
</schema>
Creates a Business Object Model called ExampleSchema.bom with the following:
Included Schemas
XML schemas can include other schema of the same target namespace. Included schemas are merged into a single Business Object Model.
Imported Schemas
If ExampleSchema.xsd has the following <import> construct:
<import namespace="http://www.example.org/ImportedSchema" schemaLocation="ImportedSchema.xsd"/>
Then in addition to ExampleSchema.bom another BOM is generated called org.example.imported.schema.bom with the following details
XSD SimpleType
Basic SimpleType
XML Schema SimpleType constructs are mapped directly to a Business Object Model PrimitiveType. For example:
<simpleType name="SimpleType2">
 <restriction base="string" />
</simpleType>
Maps to:
XML schema to Business Object Model data type mappings are described in section Data Type Mappings
SimpleType that Extends Another SimpleType
The following XML schema construct:
<simpleType name="SimpleType3">
 <restriction base="tns:SimpleType2" />
</simpleType>
<simpleType name="SimpleType2">
 <restriction base="string" />
</simpleType>
Maps to:
 
Note that SimpleType3 extends (generalizes) SimpleType2.
Annotation within SimpleType
The following XML schema construct:
<simpleType name="SimpleTypeAnnot">
 <annotation>
  <documentation>Annotation to a SimpleType</documentation>
 </annotation>
  <restriction base="integer"></restriction>
</simpleType>
Maps to:
 
The text contained within the <documentation> tag will be visible in the Description tab of the Business Object Model PrimitiveType property sheet.
XSD Complex Type
XML Schema ComplexType constructs are mapped directly to a Business Object Model Class. Element and attribute constructs within the ComplexType will map to Business Object Model attributes with multiplicity dependent on context (see examples below).
ComplexType with Attributes and Sequence of Elements
The following XML schema construct:
<complexType name="Address">
 <sequence>
  <element name="firstName" type="string" />
  <element name="lastName" type="string" />
  <element name="firstLineAdress" type="string" />
  <element name="city" type="string" />
  <element name="region" type="string" />
<element name="postcode" type="string" />
 </sequence>
 <attribute name="id" type="integer" />
</complexType>
Maps to:
Note that <element> constructs, in the absence of any maxOccurs and minOccurs facets, map by default to a Business Object Model attribute with multiplicity of 1. The <attribute> construct will always map to a Business Object Model attribute with multiplicity 0..1, reflecting the optional nature of an XSD attribute.
ComplexType with Element of Type ComplexType
The following XML schema construct:
<complexType name="BankCustomer">
 <sequence>
  <element name="id" type="integer" />
  <element name="name" type="string"></element>
  <element name="account" type="tns:Account" />
 </sequence>
</complexType>
<complexType name="Account">
 <sequence>
  <element name="number" type="integer" />
 </sequence>
</complexType>
Maps to:
 
In this example, Account is a ComplexType and hence represented as a Class on the Business Object Model. The BankCustomer Class, subsequently, has a composition relationship with Account representing the "account" <element>.
ComplexType with SimpleContent
The following XML schema construct:
<simpleType name="SimpleType">
 <restriction base="string">
 </restriction>
</simpleType>
 
<complexType name="ComplexType">
 <simpleContent>
  <extension base="tns:simpleType" />
 </simpleContent>
</complexType>
Maps to:
Note that the <simpleContent> construct maps to a Class attribute with multiplicity 0..1. The anonymous nature of the <simpleType> construct meant that the Business Object Model had to assign the name "value" to its attribute.
ComplexType with ComplexContent Extension
The following XML schema construct:
<complexType name="Person">
 <sequence>
  <element name="name" type="string"></element>
 </sequence>
</complexType>
 
<complexType name="Customer">
 <complexContent>
 <extension base="tns:Person">
 <sequence>
  <element name="id" type="string"></element>
 </sequence>
 </extension>
 </complexContent>
</complexType>
Maps to:
 
The Business Object Model creates a Generalization relationship between the Customer and Person Classes.
ComplexType with ComplexContent Restriction
The following XML schema construct:
<complexType name="shoppingBasket">
 <sequence>
  <element name="productId" type="positiveInteger"   maxOccurs="unbounded"/>
 </sequence>
</complexType>
 
<complexType name="basketCapped">
 <complexContent>
 <restriction base="tns:shoppingBasket">
 <sequence>
  <element name="productId" type="positiveInteger" maxOccurs="5" />
 </sequence>
 </restriction>
 </complexContent>
</complexType>
Maps to:
Note that the multiplicity of productId in the basketCapped class is represented by a 1..n, that is, more restrictive that the shoppingBasket class productId that has unbounded multiplicity.
Anonymous ComplexType
The following XML schema construct:
<complexType name="Ct1">
 <sequence>
  <element name="Elem">
  <complexType>
 <sequence>
  <element name="anon" type="string"></element>
 </sequence>
  </complexType>
  </element>
 </sequence>
</complexType>
Maps to:
 
The anonymous ComplexType within the "elem" element means "elem" is represented as a Class on the Business Object Model, with an assigned name of "ElemType". The containment of "ElemType" within "ct1" is represented by a Composition relationship.
Annotation within ComplexType
The <documentation> information in the following XML schema constructs will be visible in the Description tab of the Business Object Model PrimitiveType property sheet.
The following XML schema construct:
<complexType name="ComplexTypeAnnot">
 <annotation>
 <documentation>Annotation to a ComplexType</documentation>
 </annotation>
</complexType>
Maps to:
 
ComplexType with Mixed Construct
The following XML schema construct:
<xs:complexType name="Car" mixed="true">
<xs:sequence>
<xs:element name="colour" type="xs:string" />
</xs:sequence>
</xs:complexType>
Maps to:
ComplexContent with Mixed Construct
The following XML schema construct:
<xs:complexType name="Car">
<xs:complexContent mixed="true">
<xs:extension base="SuperCar">
<xs:sequence>
<xs:element name="engine" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Maps to:
A mixed complex content can only exist if it extends another complex type that is also labelled as mixed.
See http://www.w3.org/TR/xmlschema11-1/#dcl.ctd.ctcc.common
XSD Global Elements
XML schema global elements and attributes do not translate directly into Business Object Model (i.e. UML) data. However, they do need to be represented by some means so that they can be reconstructed in exported XML schema, if the Business Object Model originated from an XML schema import.
Simple Element and Attribute Type
The following XML schema construct:
<schema>
 <element name="TestStringData" type="string"></element>
</schema>
Maps to Business Object Model Primitive Type:
A stereotype is applied to the "TestStringData" PrimitiveType identifying it as a XSD global element.
Element of Complex Type
The following XML schema construct:
<element name="PersonElement" type="Person"></element>
<complexType name="Person">
 <sequence>
  <element maxOccurs="1" minOccurs="1" name="name">
  <simpleType>
  <restriction base="string">
  <maxLength value="50"></maxLength>
  </restriction>
  </simpleType>
  </element>
 </sequence>
</complexType>
Maps to a Business Object Model Class representing the Person ComplexType:
 
Maps to:
 
The global element "PersonElement" is not represented directly on the Business Object Model diagram. Instead, the Class "Person" has a stereotype applied to it that stores data representing all the global elements in the original schema that were of this type.
Top Level Enumeration Elements
The following XML schema construct:
<element name="topElement" type="SubAccountType"></element>
<simpleType name="SubAccountType">
 <restriction base="string">
 <enumeration value="Cash"></enumeration>
 <enumeration value="Margin"></enumeration>
 <enumeration value="Income"></enumeration>
 <enumeration value="Short"></enumeration>
 <enumeration value="DVP/RVP"></enumeration>
 <enumeration value="Dividend"></enumeration>
 </restriction>
</simpleType>
Maps to a Business Object Model Class representing the SubAccountType ComplexType:
 
 
The appropriate stereotype information represents the global element "topElement".
 

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved