Home » Developer & Programmer » JDeveloper, Java & XML » Improper parsing of xml schema (jdk 1.6)
Improper parsing of xml schema [message #566586] Mon, 17 September 2012 13:22 Go to next message
tigsav
Messages: 49
Registered: April 2012
Member
Hello All,

I have used jaxb (used xjc.exe ) to parse a XML schema file.However after the class files were generated,one of the setter method is missing.Is it possible that this can happen or have i done something wrong.

the XSD file is

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="shiporder">
<xs:complexType>
<xs:sequence>
<xs:element name="orderperson" type="xs:string"/>
<xs:element name="shipto">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="note" type="xs:string" minOccurs="0"/>
<xs:element name="quantity" type="xs:positiveInteger"/>
<xs:element name="price" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="orderid" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>



The classes that got generated are (snippet of it)



public class Shiporder {

@XmlElement(required = true)
protected String orderperson;
@XmlElement(required = true)
protected Shiporder.Shipto shipto;
@XmlElement(required = true)
protected List<Shiporder.Item> item;
@XmlAttribute(name = "orderid", required = true)
protected String orderid;

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

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

/**
* Gets the value of the shipto property.
*
* @return
* possible object is
* {@link Shiporder.Shipto }
*
*/
public Shiporder.Shipto getShipto() {
return shipto;
}

/**
* Sets the value of the shipto property.
*
* @param value
* allowed object is
* {@link Shiporder.Shipto }
*
*/
public void setShipto(Shiporder.Shipto value) {
this.shipto = value;
}

/**
* Gets the value of the item property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the item property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getItem().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Shiporder.Item }
*
*
*/
public List<Shiporder.Item> getItem() {
if (item == null) {
item = new ArrayList<Shiporder.Item>();
}
return this.item;
}

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

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


/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="title" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="note" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="quantity" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
* &lt;element name="price" type="{http://www.w3.org/2001/XMLSchema}decimal"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"title",
"note",
"quantity",
"price"
})
public static class Item {

@XmlElement(required = true)
protected String title;
protected String note;
@XmlElement(required = true)
@XmlSchemaType(name = "positiveInteger")
protected BigInteger quantity;
@XmlElement(required = true)
protected BigDecimal price;

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

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

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

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

/**
* Gets the value of the quantity property.
*
* @return
* possible object is
* {@link BigInteger }
*
*/
public BigInteger getQuantity() {
return quantity;
}

/**
* Sets the value of the quantity property.
*
* @param value
* allowed object is
* {@link BigInteger }
*
*/
public void setQuantity(BigInteger value) {
this.quantity = value;
}

/**
* Gets the value of the price property.
*
* @return
* possible object is
* {@link BigDecimal }
*
*/
public BigDecimal getPrice() {
return price;
}

/**
* Sets the value of the price property.
*
* @param value
* allowed object is
* {@link BigDecimal }
*
*/
public void setPrice(BigDecimal value) {
this.price = value;
}

}

This does not contain setitem() method .
Can anybody explain why this is happening?
Re: Improper parsing of xml schema [message #566832 is a reply to message #566586] Thu, 20 September 2012 02:26 Go to previous message
tigsav
Messages: 49
Registered: April 2012
Member
Hello all ,

The method is actually inherited from Lists .Hence it not available.Sorry for that one.
Previous Topic: rss feed generation
Next Topic: Problem with XML
Goto Forum:
  


Current Time: Thu Mar 28 03:47:37 CDT 2024