Werner Guttmann wrote:
> 
> 
> 
> azimo wrote:
>> Hi again.
>> 
>> Thanks for the answers, snipping to ask additional questions.
>> 
>> 
>> Werner Guttmann wrote:
>>> Yes. As already explained, a minOccurs="0" indicates that the element
>>> can be (optionally) included in your XML, but this is not mandatory. And
>>> this is an exclusive OR: either it is included or it is not. When it is
>>> included, the fact that it is included mandates that it has to meet the
>>> remainder of the criteria in your XML schema.
>>>
>>> In your case - and here I am taking the XML schema fragment from below -
>>>  this implies that if there's an
>>>
>>> <SomeNiceElementName> ...</SomeNiceElementName>
>>>
>>> included in your XML, its value space is that of <xs:integer> and the
>>> value has to meet the 'totalDigits' facet as well. In other words,
>>> having
>>>
>>> <SomeNiceElementName></SomeNiceElementName>
>>>
>>> or
>>>
>>> <SomeNiceElementName/>
>>>
>>> would be invalid and violate the element definition (aka anonymous
>>> simple type definition specified).
>>>
>> Shouldn't the unmarshalling produce an error then based on the schema
>> definition below??
> Yes, it actually should. Let me ask you a few questions:
> 
> a) You have used the Castor XML code generator to generate code from
> your XMl schema, correct  ?
> b) If so, have you compiled the generated descriptor classes and made
> them available on the class path ?
> 
>> As it is now, if I have:
>> 
>> <SomeNiceElementName></SomeNiceElementName>
>> 
>> then a value of 0 appears in the attribute mapping to the element during
>> the
>> unmarshalling.
>> 
>> 
>> Werner Guttmann wrote:
>>>> Definiton of element:
>>>>
>>>> <xs:element name="SomeNiceElementName" minOccurs="0">
>>>>   <xs:annotation>
>>>>     <xs:documentation/>
>>>>   </xs:annotation>
>>>>   <xs:simpleType>
>>>>     <xs:restriction base="xs:integer">
>>>>       <xs:totalDigits value="5"/>
>>>>     </xs:restriction>
>>>>   </xs:simpleType>
>>>> </xs:element>
>>>>
>>>> Some additional info. This is an element not defined by me. The problem
>>>> we
>>>> have is something I am simply dabbling with on the side, I don't know
>>>> enough
>>>> of XML schemas to say if that is poorly written or not.
>>> Yes, it is, if there's a requirement that this element should be able to
>>> carry 'null' values. I hope that my comments above make things clearer
>>> to you.
>>>
>>>> I also understand
>>>> that not having the element present in the XML vs. getting an empty
>>>> element
>>>> in the XML is not the same thing, I would just like to know if there is
>>>> a
>>>> nice and simple way of making it the same thing (usually I have little
>>>> or
>>>> no
>>>> use for an empty string "" or 0 and would in many instances always want
>>>> to
>>>> set NULL to an attribute that receives this).
>>> Not the same thing, but you could use the 'nillable' attribute on the
>>> element definition, and allow out-ouf-band signals about emptiness.
>>>
>> Is "nillable" the only solution or could the "poorly" written schema be
>> written in a better way so that it still means optional but when an empty
>> tag appears it doesn't try to add a default value for that type (in this
>> case integer and the value of 0)??
> Let's first see what your answers are to my question above ?
>> 
>> Thanks again,
>> 
>> Archie
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 
> 
> 
I believe the answer to both a) and b) are yes but I must check with the
guys who are actually working on this. I will get them to read this thread
too and then I will answer back tomorrow.

Thanks for the correspondence so far,

Archie
-- 
View this message in context: 
http://www.nabble.com/Unmarshalling-XML-with-null-values--tp16993226p17049963.html
Sent from the Castor - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to