Please show us the code with which you build the element.
It is as I wrote: if you call the setter the fieldBytesLength isn't null any
more, and the attribute appears, even when it's zero.
The class name in the code you posted is "T15Field"; in the schema it's
Field - that's funny?
-W
On Tue, Jul 21, 2009 at 1:40 PM, ofira shaer <oshaer_at_gmail.com> wrote:
> I do call it, but it doesn't help. the attribute does not appear in the
> XML... I guess that even if i don't set it, it should appear as:
>
> <Field FieldBytesLength="0">
> <FieldName>MY_NAME</FieldName>
> <FieldValue>02</FieldValue>
> </Field>
>
> But it is missing...
>
>
> 2009/7/21 Wolfgang Laun <wolfgang.laun_at_gmail.com>
>
> Do you call setFieldBytesLength to set a value?
>>
>> If you don't, the default defined in the schema applies, and if you
>> unmarshal or just call getFieldBytesLength(), you'd get that value, i.e.,
>> zero.
>>
>> -W
>>
>>
>>
>> On Mon, Jul 20, 2009 at 6:02 PM, ofira shaer <oshaer_at_gmail.com> wrote:
>>
>>> 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.
>>>
>>> *
>>>
>>> * *_at_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.
>>>
>>> *
>>>
>>> * *_at_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.
>>>
>>>
>>
>>