Type Support in XML Maps

This topic describes the default schema output for Java types you translate using an XML map. When you use XML maps to create and outgoing XML message, WebLogic Server maps Java types to XML schema types as described in this topic. This topic lists each Java type supported by XML maps and shows the corresponding schema definition for each.

Note: The default behavior is different for XML generated through ECMAScript in a JSX file, even though it is funneled through an XML map. For XML you create with script, the default is simple untyped XML. You must indicate schema (where needed) in script by creating XML variables, then assigning to them XML values that include literal schema attributes.

Here are the Java types supported by XML maps:

- String

- boolean

- byte

- short

- int

- long

- Single-precision float

- Double-precision float

- Date

- Typed arrays

- Lists

- Structure

- JavaBeans with public get and set method

- XML element

- XML document fragment

# Information Given in This List

Each item in this list includes the following:

Java code that might be used to declared a variable of the type:

String a = "a string";

An example of the variable as it might appear in an XML map:

<mytag>{a}</mytag>

An example of the plain XML the map would produce (or handle, for incoming messages):

<mytag>a string</mytag>

An example of how the variable would be described in a WSDL file. You're unlikely to use this information directly while using WebLogic Workshop because WebLogic Server handles the translation. But in other development models, where messages must be handled directly, this information can be valuable.

<s:element name="mytag" type="s:string"/>

# String

Java Variable | String a = "a string";
XML Map Use | <mytag>{a}</mytag>
XML Result | <mytag>a string</mytag>
Schema for Result | <s:element name="mytag" type="s:string"/>

# Boolean

Java Variable | boolean f = true;
XML Map Use | <mytag>{f}<mytag>
XML Result | <mytag>true</mytag>
Schema for Result | <s:element name="mytag" type="s:boolean"/>

# Byte

Java Variable | byte b = 250;
XML Map Use | <mytag>{b}<mytag>
XML Result | <mytag>250</mytag>
Schema for Result | <s:element name="mytag" type="s:byte"/>

# Short Integer

Java Variable | short s = 537;
XML Map Use | <mytag>{s}</mytag>
XML Result | <mytag>537</mytag>
Schema for Result | <s:element name="mytag" type="s:shortint"/>

# Integer

Java Variable | int i = 12345;
XML Map Use | <mytag>{i}</mytag>
XML Result | <mytag>12345</mytag>
Schema for Result | <s:element name="mytag" type="s:int"/>

# Long Integer

Java Variable | long l = 123456789;
XML Map Use | <mytag>{l}</mytag>
XML Result | <mytag>123456789</mytag>
Schema for Result | <s:element name="mytag" type="s:longint"/>

# Single-Precision Floating Point Number

Java Variable | float f = 1.23f;
XML Map Use | <mytag>{f}</mytag>
XML Result | <mytag>1.23</mytag>
Schema for Result | <s:element name="mytag" type="s:floatingpoint"/>

# Double-Precision Floating Point Number

Java Variable | float d = 1.2345;
XML Map Use | <mytag>{f}</mytag>
XML Result | <mytag>1.2345</mytag>
Schema for Result | <s:element name="mytag" type="s:doublefloat"/>

# Date

Java Variable | java.util.Date date= new java.util.Date();
XML Map Use | <mytag>{date}</mytag>
XML Result | <mytag>2002-04-14T13:57:12.046Z</mytag>
Schema for Result | <s:element name="mytag" type="s:dateTime"/>

# Typed Arrays of Any of the Preceding Types

Java Variable | String[] sa = new String[] {"first", "second", "third"};
XML Map Use | <mytag>{sa}</mytag>
XML Result | <mytag> <String>first</String> <String>second</String> <String>third</String> </mytag>
Schema for Result | <s:element name="mytag" type="s0:ArrayOfString"/> <s:complexType name="ArrayOfString"> <s:sequence> <s:element minOccurs="0" maxOccurs="unbounded" name="String" nillable="true" type="s:string" /> </s:sequence> </s:complexType>

# List

The following examples describe how an entire list is translated to XML when mapped as a single unit. You can also map individual members of a list as described in Handling Repeating XML Values with <xm:multiple> and Declaring Variables with <xm:bind>.

XML maps support subclasses of the Collection class, including the following:

- Collection

- AbstractCollection

- AbstractList

- AbstractSequentialList

- LinkedList

- ArrayList

- Vector

- AbstractSet

- HashSet

- TreeSet

- List

However, the following are not supported:

- AbstractMap

- HashMap

- TreeMap

- WeakHashMap

- Map

- HashTable

- Iterator

- ListIterator

- Enumeration

Java Variable | ArrayList list = new ArrayList(); list.add("first"); list.add("second"); list.add(new Integer(71));
XML Map Use | <mytag>{list}</mytag>
XML Result | <mytag> <anyType xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">first</anyType> <anyType xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">second</anyType> <anyType xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:int">71</anyType> </mytag>
Schema for Result | <s:element name="mytag" type="s0:List" /> <s:complexType name="List"> <s:sequence> <s:element minOccurs="0" maxOccurs="unbounded" name="anyType" nillable="true" type="s:anyType" /> </s:sequence> </s:complexType>

# Structure

The following examples describe how an entire structure is translated to XML when mapped as a single unit. You can also map individual members of a structure as described in Binding to Java Data Members.

Java Variable | static public class Structure { public int intField = 43; public String stringField = "member2"; } Structure s = new Structure();
XML Map Use | <mytag>{s}</mytag>
XML Result | <mytag> <intField>43</intField> <stringField>member2</stringField> </mytag>
Schema for Result | <s:element name="mytag" type="s0:Structure" /> <s:complexType name="Structure"> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="intField" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="stringField" nillable="true" type="s:string" /> </s:sequence> </s:complexType>

# JavaBeans with Public get and set Method

The following examples describe how get/set pairs are translated to XML when mapped as a single unit. You can also map individual members as described in Binding to Java Data Members.

Java Variable | static public class Bean { public String getName() { return theName; } public void setName(String s) { theName = s; } private String theName = "A name"; public int getNumber() { return theNumber; } public void setNumber(int i) { theNumber = i; } private int theNumber = 8; } Bean b = new Bean();
XML Map Use | <mytag>{b}</mytag>
XML Result | <mytag> <name>A name</name> <number>8</number> </mytag>
Schema for Result | <s:element name="mytag" type="s0:Bean" /> <s:complexType name="Bean"> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="name" nillable="true" type="s:string" /> <s:element minOccurs="1" maxOccurs="1" name="number" type="s:int" /> </s:sequence> </s:complexType>

# XML Element

Java Variable | Document myDocument = new weblogic.apache.xerces.dom.DocumentImpl(); Text text = myDocument.createTextNode("This is a root element"); Element root = myDocument.createElement("myRootElement"); root.appendChild(text); myDocument.appendChild(root);
XML Map Use | <mytag>{root}</mytag>
XML Result | <mytag> <myRootElement>This is a root element</myRootElement> <mytag>
Schema for Result | <s:element name="mytag"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="mytag"> <s:complexType mixed="true"> <s:sequence> <s:any /> </s:sequence> </s:complexType> </s:element> </s:sequence> </s:complexType> </s:element>

# XML Document Fragment

Java Variable | Document myDocument = new weblogic.apache.xerces.dom.DocumentImpl(); DocumentFragment frag = myDocument.createDocumentFragment(); Text text = myDocument.createTextNode("Some fragment text"); Element sibling = myDocument.createElement("testElement"); sibling.appendChild(text); frag.appendChild(sibling); Text text2 = myDocument.createTextNode("More fragment text"); Element sibling2 = myDocument.createElement("testElement2"); sibling2.appendChild(text2); frag.appendChild(sibling2);
XML Map Use | <mytag>{frag}</mytag>
XML Result | <mytag> <testElement>Some fragment text</testElement> <testElement2>More fragment text</testElement2> </mytag>
Schema for Result | <s:element name="mytag"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="mytag"> <s:complexType mixed="true"> <s:sequence> <s:any /> </s:sequence> </s:complexType> </s:element> </s:sequence> </s:complexType> </s:element>

Related Topics

Type Support in ECMAScript