When you are mapping XML elements with enumeration in the XML mapping editor, an XSL Choose provides a way to conditionally set target elements. This topic uses an example to show you how to use XSL Choose to map XML elements that use enumeration.
<xsd:complexType name="SourceBOwithEnum"> <xsd:sequence> <xsd:element name="addressTypeIndicator" type="se:IndicatorTypes"> <xsd:annotation> <xsd:documentation> Indicates the location for delivery </xsd:documentation> </xsd:annotation> </xsd:element> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="IndicatorType"> <xsd:annotation> <xsd:documentation> Type defining an indicator as 1 character </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:string"> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="IndicatorTypes"> <xsd:restriction base="se:IndicatorType"> <xsd:enumeration value="1" /> <xsd:enumeration value="2" /> <xsd:enumeration value="3" /> </xsd:restriction> </xsd:simpleType>
<xsd:complexType name="TargetBOwithEnum"> <xsd:sequence> <xsd:element name="shipToAddressTypeIndicator" type="te:shipToAddressTypes"> <xsd:annotation> <xsd:documentation> Indicates that the mailing address is the same as the business address. </xsd:documentation> </xsd:annotation> </xsd:element> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="shipToAddressType"> <xsd:annotation> <xsd:documentation> Type defining an indicator as 1 character </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:string"> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="shipToAddressTypes"> <xsd:restriction base="te:shipToAddressType"> <xsd:enumeration value="Warehouse 1" /> <xsd:enumeration value="Warehouse 2" /> <xsd:enumeration value="default location" /> </xsd:restriction> </xsd:simpleType>
The following image shows the source and target schema
described above in the XML mapping editor.
Map the elements using the procedure described below. For step by step instructions on defining XSL choose, see Adding <xsl:choose>instructions to your mapping:
<?xml version="1.0" encoding="UTF-8"?> <se:invoke xmlns:se="http://MappingEnum/SourcewithEnum" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://MappingEnum/SourcewithEnum SourcewithEnum.xsd "> <se:addressTypeIndicator>1</se:addressTypeIndicator> </se:invoke>
<?xml version="1.0" encoding="UTF-8"?> <te:invoke xmlns:te="http://MappingEnum/TargetwithEnum" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <te:shipToAddressTypeIndicator>Warehouse 1</te:shipToAddressTypeIndicator> </te:invoke>