users@jaxb.java.net

Where is my attribute?

From: ofira shaer <oshaer_at_gmail.com>
Date: Mon, 20 Jul 2009 19:02:35 +0300

 Hi.
I have an attribute that is missing from the resulted xml. What am i doing
wrong?

schema section:

<xs:complexType name="Field">
*

<xs:sequence>
*

<xs:element *ref*="FieldName"/>

<xs:element name="FieldValue" type="xs:string"/>
*

</xs:sequence>
*

<xs:attribute name="FieldBytesLength" type="xs:int" default="0"
use="optional"/>
</xs:complexType>

generated code:


*

public class T15Field {

@XmlElement(name = "FieldName", required = true)

protected String fieldName;

@XmlElement(name = "FieldValue", required = true)

protected String fieldValue;

@XmlAttribute(name = "FieldBytesLength")

protected Integer fieldBytesLength;

.......

  /**

* Gets the value of the fieldBytesLength property.

*

* @return

* possible object is

* {_at_link Integer }

*

*/

public int getFieldBytesLength() {

if (fieldBytesLength == null) {

return 0;

} else {

return fieldBytesLength;

}

}

/**

* Sets the value of the fieldBytesLength property.

*

* @param value

* allowed object is

* {_at_link Integer }

*

*/

public void setFieldBytesLength(Integer value) {

this.fieldBytesLength = value;

}

*}

I instanitiate an object and set the FieldBytesLength value, yet, after
marshalling I get this:

<Field>
<FieldName>MY_NAME</FieldName>
<FieldValue>02</FieldValue>
</Field>

Where is my attribute?

Thanks.