IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Defining and transforming data > Transforming data > Transforming data using a business object map > Mapping with XSD wildcards
Substitution group mappings
In XML 1.0, the name and content of an element had to correspond exactly to the element type referenced in the corresponding content model. Through substitution groups, XML schemas provide a more powerful model supporting substitution of one named element for another.
All elements in the substitution group (the head element and the substituted elements) must be declared as global elements. The type of the substitutable elements must be the same as, or derived from, the type of the head element. If the type of the substituted element is the same as the type of the head element you will not have to specify the type of the substitutable element.
Alias patterns
Aliasing provides a convenient pattern for you to use for the head element to access whichever substitutable element is present at run time. This is only "one way" name aliasing for the head element. There is no name aliasing for substitutable elements.For example, the following substitutable elements have the same type:
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://NameSubstitution" xmlns:p="http://NameSubstitution"> <xsd:element name="name" type="xsd:string"/> <xsd:element name="navn" substitutionGroup="p:name"/> <xsd:element name="nombre" substitutionGroup="p:name"/> <xsd:complexType name="NameSubstitution"> <xsd:sequence> <xsd:element ref="p:name"/> </xsd:sequence> </xsd:complexType> </xsd:schema>You can set() or get() the "name" value in the same way regardless of whether it is a "navn" or "nombre".
DataObject dobj = ... dobj.setString("name", "foo"); dobj.setString("navn", "foo1"); dobj.setString("name", "foo2"); // result should contain foo, foo1 and foo2 result = dobj.get("name"); // result should contain foo1 only result = dobj.get("navn"); // result should contain foo2 only result = dobj.get("nombre");All map transformations are possible with substitution group elements. In the following map, the head element is the type Publication:
?xml version="1.0"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace=http://MapTests xmlns:ii="http://MapTests"> <element name="Library"> <complexType> <sequence> <element ref="ii:Publication" maxOccurs="unbounded"/ </sequence> </complexType> </element> <!--Here is a <complexType> "publication" with 2 derived types: "book" - derived by extension "magazine" - derived by restriction --> <complexType name="publication"> <sequence> <element name="Title" type="string"/> <element name="Author" type="string" minOccurs="0"/> <element ref="ii:Description"/> </sequence> </complexType> <complexType name="book"> <complexContent> <extension base="ii:publication"> <attribute name="Section" type="string" use="required"/> </extension> </complexContent> </complexType> <complexType name="magazine"> <complexContent> <restriction base="ii:publication" <sequence> <element name="Title" type="string"/> <element name="Author" type="string" minOccurs="0" maxOccurs="01"/> <element ref="ii:Description"/> </sequence> </restriction> </complexContent> </complexType> <element name="Publication" type="ii:publication"/> <element name="Book" type="ii:book" substitutionGroup="ii:Publication"/> <element name="Magazine" type="ii:magazine" substitutionGroup="ii:Publication"/> <!--Here is a <simpleType> "desc" with 2 derived types:"shortDesc" - <simpleType> derived by restriction "foreignDesc" - <complexType> derived by extension <simpleType name="desc"> <restriction base="string"> <minLength value="1"/> </restriction> </simpleType> <simpleType name="shortDesc"> <restriction base="ii:desc"> <maxLength value="30"/> </restriction> </simpleType> <complexType name="foreignDesc"> <simpleContent> <extension base="ii:desc"> <attribute name="Language" type="string" use="required"/> </extension> </simpleContent> </complexType> <element name="Description" type="ii:desc"/> <element name="ShortDesc" type="ii:shortDesc" substitutionGroup="ii:Description"/><element name="ForeignDesc" type="ii:foreignDesc" substitutionGroup="ii:Description"/> </schema>Elements in a substitution group can be substituted for each other and if the parent map is defined on the head element (Publication) then a submap which is created on one of the other elements in the substitution group (Book) can be used for input to the submap. This is possible as Book is a type of Publication:
A warning is generated if there is a map defined on the head element (for example, Publication) and also a map defined on one or more of the substitution group element (for example, Book or Magazine). This is because if at run time an instance of the head element is passed to the map then both the transform on the head element and the substitution group element will run. As the substitutable group element is derived from the head element, depending on the order of the transform, the last one to run will overwrite the values written by the previous one.
If a submap exists on Publication and another submap exists on Magazine and the runtime instance data created is of Type Publication, then a BookStore.get(“Publication”) would return a DataObject causing the submap transform to run. A BookStore.get(“Magazine”) would also return a DataObject causing the second submap transform to run. You should choose to have the submap or any other transform to be either on the head element or the substitution group element to prevent the transformations from overwriting each other's data because of the derived type nature of substitution group elements.