Skip to main content

Code generation for xs:union

1 reply [Last post]
alikic
Offline
Joined: 2005-10-24
Points: 0

Hi,

I am switching from JAXB1.0 to 2.0, and I observed a change in the code generated for xs:union. While before the property generated for the xs:union element (for my schema) was java.lang.Comparable, now I see it is java.lang.String. Is that an expected behaviour?

Thanks

Here are my schema and the generated classes:

<?xml version="1.0" encoding="UTF-8"?>

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0-20051023-EA2
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2005.10.24 at 10:19:21 PM EDT
//

package ca.itsys.api.stamp.schema;

import javax.xml.bind.annotation.XmlEnum;
import ca.itsys.api.stamp.schema.DescriptivePrice;

/**
* Java class for DescriptivePrice.
*
* The following schema fragment specifies the expected content contained within this class.
*
*

 * <simpleType name="DescriptivePrice">
*   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
*     <enumeration value="MARKET"/>
*     <enumeration value="PRICE"/>
*   </restriction>
* </simpleType>
*

*
*/
@XmlEnum
public enum DescriptivePrice {

MARKET,
PRICE;

public String value() {
return name();
}

public DescriptivePrice fromValue(String v) {
return valueOf(v);
}

}

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0-20051023-EA2
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2005.10.24 at 10:19:21 PM EDT
//

package ca.itsys.api.stamp.schema;

import javax.xml.bind.annotation.AccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import ca.itsys.api.stamp.schema.Quote;

/**
* Java class for Quote element declaration.
*
* The following schema fragment specifies the expected content contained within this class.
*
*

 * <element name="Quote">
*   <complexType>
*     <complexContent>
*       <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
*         <sequence>
*           <element name="BuyPrice" type="{}Price"/>
*         </sequence>
*       </restriction>
*     </complexContent>
*   </complexType>
* </element>
*

*
*
*/
@XmlAccessorType(AccessType.FIELD)
@XmlType(name = "", propOrder = {
"buyPrice"
})
@XmlRootElement(name = "Quote")
public class Quote {

@XmlElement(name = "BuyPrice")
protected String buyPrice;

/**
* Gets the value of the buyPrice property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getBuyPrice() {
return buyPrice;
}

/**
* Sets the value of the buyPrice property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setBuyPrice(String value) {
this.buyPrice = value;
}

}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09
Points: 0

Yes, it is expected now. Union used to bind to the common base type of all the member types, so in your case you would either get String that reprsents two constants or BigInteger for decimal.

In 2.0, due to the architectual change we can't do something like this anymore. So you always just get String.