You can use this mapping between XML types and Java types when using external functions and variables. They are recommended mappings only; other types might work subject to type promotion, casting rules, and the range of values representable by the target type.
Built-in Types | Java Types |
---|---|
xs:anyURI | java.lang.String |
xs:boolean | boolean, java.lang.Boolean |
xs:base64Binary | byte[] |
xs:hexBinary | byte[] |
xs:date | javax.xml.datatype.XMLGregorianCalendar |
xs:dateTime | javax.xml.datatype.XMLGregorianCalendar |
xs:time | javax.xml.datatype.XMLGregorianCalendar |
xs:duration | javax.xml.datatype.Duration |
xs:dayTimeDuration | javax.xml.datatype.Duration |
xs:yearMonthDuration | javax.xml.datatype.Duration |
xs:gDay | javax.xml.datatype.XMLGregorianCalendar |
xs:gMonth | javax.xml.datatype.XMLGregorianCalendar |
xs:gMonthDay | javax.xml.datatype.XMLGregorianCalendar |
xs:gYear | javax.xml.datatype.XMLGregorianCalendar |
xs:gYearMonth | javax.xml.datatype.XMLGregorianCalendar |
xs:decimal | java.math.BigDecimal |
xs:integer | java.math.BigInteger |
xs:nonPositiveInteger | java.math.BigInteger |
xs:negativeInteger | java.math.BigInteger |
xs:long | long, java.lang.Long |
xs:int | int, java.lang.Integer |
xs:short | short, java.lang.Short |
xs:byte | byte, java.lang.Byte |
xs:nonNegativeInteger | java.math.BigInteger |
xs:unsignedLong | java.math.BigInteger |
xs:unsignedInt | long |
xs:unsignedShort | int |
xs:unsignedByte | short |
xs:positiveInteger | java.math.BigInteger |
xs:double | double, java.lang.Double |
xs:float | float, java.lang.Float |
xs:QName | javax.xml.namespace.QName |
xs:NOTATION | javax.xml.namespace.QName |
xs:string | java.lang.String |
xs:normalizedString | java.lang.String |
xs:token | java.lang.String |
xs:language | java.lang.String |
xs:NMTOKEN | java.lang.String |
xs:Name | java.lang.String |
xs:NCName | java.lang.String |
xs:ID | java.lang.String |
xs:IDREF | java.lang.String |
xs:ENTITY | java.lang.String |
xs:untypedAtomic | java.lang.String |
List | com.ibm.xml.xapi.XItemView[] |
Union | com.ibm.xml.xapi.XItemView |
All of the above-listed built-in types | com.ibm.xml.xapi.XItemView |
com.ibm.xml.xapi.XSequenceCursor | |
Complex types (types that represent nodes in the XML document) | com.ibm.xml.xapi.XItemView |
com.ibm.xml.xapi.XSequenceCursor | |
org.w3c.dom.Node |
The mapping also applies to retrieving values from an XItemView. The XItemView getDoubleValue method returns Java primitive double; the getDateValue, getTimeValue, and getDateTimeValue methods all return an XMLGregorianCalendar; and so on.
If you want to use an external function in your XPath or XQuery expressions and it takes a built-in type as the argument, the actual Java method signature can specify any of the indicated Java types. If you want to use an external function, my:power(arg1 as xs:int, arg2 as xs:int) for example, to calculate the value of the first argument raised to the power of the second argument, you could write a Java method taking two Java primitive int arguments that performs the calculation.
Sequence Types | Java Types |
---|---|
All sequence types | com.ibm.xml.xapi.XSequenceCursor |
Sequence type known to be a singleton (a sequence containing only one item) | com.ibm.xml.xapi.XItemView |
One of the types listed in the built-in types to Java types mapping table | |
Sequence type known to contain only nodes and no atomic items | org.w3c.dom.NodeList |
org.w3c.dom.traversal.NodeIterator |
In this information ... | IBM Redbooks, demos, education, and more(Index) Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience. This feature requires Internet access. Most of the following links will take you to information that is not part of the formal product documentation and is provided "as is." Some of these links go to non-IBM Web sites and are provided for your convenience only and do not in any manner serve as an endorsement by IBM of those Web sites, the material thereon, or the owner thereof. |