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 type (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:
Each item in this list includes the following:
String a = "a string";
<mytag>{a}</mytag>
<mytag>a string</mytag>
<s:element name="mytag" type="s: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"/> |
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"/> |
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"/> |
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"/> |
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"/> |
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"/> |
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"/> |
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"/> |
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"/> |
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> |
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:
However, the following are not supported:
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> |
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> |
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> |
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> |
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> |