How to handle xsi:nil="true" and a required attribute

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to handle xsi:nil="true" and a required attribute

forums
.... Please consider the following snippet of a xsd that I have to deal with:

..... ..... As you can see, the VALUEelement is nillabel and the UOM
attribute is required. How should I use JAXB generated classes to marshall
them to the following valid XML: The problem is that in order to get
xsi:nil=true I have to set "VALUE" to NULL. This marshalls to the invalid XML
(required UOM attribute is not there): But how can I set the required UOM
attribute "cm" if it is earlier set to NULL? Is there a workaround? Please
help?

--

[Message sent by forum member 'visuel']

View Post: http://forums.java.net/node/889876


Reply | Threaded
Open this post in threaded view
|

Re: How to handle xsi:nil="true" together with a required ...

forums
Hi, To be honest it's not very clear what are you trying to do. First of all,
your mentioned XML is not included (I think because of some formating in your
post). And regarting your question why do you need to set UOM if VALUE is
null?

--

[Message sent by forum member 'yaroska']

View Post: http://forums.java.net/node/889876


Reply | Threaded
Open this post in threaded view
|

Re: How to handle xsi:nil="true" together with a required ...

forums
Thanks for your reaction. I hope the XML is visible now. I want to set UOM
because the XSD requires me to do so (attribute UOM is required). Otherwise
the XML is not valid. I agree with you that it is not logical to set the uom
to any value when VALUE = null, but again the validation rules force me to it
and JAXB generated code won't let me.

--

[Message sent by forum member 'visuel']

View Post: http://forums.java.net/node/889876


Reply | Threaded
Open this post in threaded view
|

Re: How to handle xsi:nil="true" together with a required ...

forums
I hope it's not bad form to reply to an old post. I'm trying to solve this
exact problem. Visuel or anyone else, is there a way to do this?

--

[Message sent by forum member 'mfisch04']

View Post: http://forums.java.net/node/889876