You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Michael Wirz <mi...@abs.de> on 2005/11/23 18:27:19 UTC

how to suppress xsi:nil="true" attributes in xml text

Hello XML Beans Users,

I am using xmlBeans to create xml Documents. As usual I call all the setters
of the elements and do a .xmlText(XmlOptions) or a .save(XmlOptions).
Wherever I had passed null to the setter methods I find a xsi:nil="true"
attribute, e.g. <Ort xsi:nil="true"></Ort>

First question: Why does that happen?
Second question: How can I suppress this behaviour?
I didnt find any option in Xmloptions that looked like it was it.

Thanks for your help,
Michael Wirz

-- 
abs IT Service GmbH
abs gruppe
Michael Wirz
Entwicklung

Landsberger Straße 57
82266 Stegen am Ammersee
Telefon: +49 (0)8143 999 43
Telefax: +49 (0)8143 999 49

Michael.Wirz@abs.de
www.eFonds24.de


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: how to suppress xsi:nil="true" attributes in xml text

Posted by Michael Wirz <mi...@abs.de>.
Thank you, Sam, for pointing this out.
It seems that it is a matter of the schema definition.

I myself dont really like this DB-style defintion of passing null-values
through an xml. My rationale would  be "easier"
a) there is a value for the tag -- fine
b) there is no value -- leave the tag emtpy

At the moment I dont have any different solution than yours:
check the data which is to be set for null, if so, dont set it - a bit
inconvinient but correct regarding XML Schema Standard.

Best regards,
Michael

> When I asked a similiar question back on 10/25,  I received this:
>
>     ----- Original Message -----
>     From: Cezar Andrei <ma...@bea.com>
>     To: user@xmlbeans.apache.org <ma...@xmlbeans.apache.org>
>     Sent: Tuesday, October 25, 2005 2:12 PM
>     Subject: RE: nilable and validate()
>
>     There is an earlier discussion on this topic, please see:
>      
>     http://www.mail-archive.com/user@xmlbeans.apache.org/msg00512.html
>      
>     Cezar
>
> which I found very helpful.  The bottom line I came up with is you
> have to test your data for null for each item that has
> *minOccurs="0".*  If it is null, then you do not want to set the
> value.  I'll be interested if you come up with a different answer.
>  
> -Sam
>  
>  
> ----- Original Message -----
> From: "Michael Wirz" < michael.wirz@abs.de <ma...@abs.de> >
> To: < user@xmlbeans.apache.org <ma...@xmlbeans.apache.org> >
> Sent: Wednesday, November 23, 2005 9:27 AM
> Subject: how to suppress xsi:nil="true" attributes in xml text
>
> > Hello XML Beans Users,
> >
> > I am using xmlBeans to create xml Documents. As usual I call all the
> setters
> > of the elements and do a .xmlText(XmlOptions) or a .save(XmlOptions).
> > Wherever I had passed null to the setter methods I find a xsi:nil="true"
> > attribute, e.g. <Ort xsi:nil="true"></Ort>
> >
> > First question: Why does that happen?
> > Second question: How can I suppress this behaviour?
> > I didnt find any option in Xmloptions that looked like it was it.
> >
> > Thanks for your help,
> > Michael Wirz
> >
> > --
> > abs IT Service GmbH
> > abs gruppe
> > Michael Wirz
> > Entwicklung
> >
> > Landsberger Straße 57
> > 82266 Stegen am Ammersee
> > Telefon: +49 (0)8143 999 43
> > Telefax: +49 (0)8143 999 49
> >
> > Michael.Wirz@abs.de <ma...@abs.de>
> > www.eFonds24.de <http://www.eFonds24.de>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> <ma...@xmlbeans.apache.org>
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> <ma...@xmlbeans.apache.org>
> >
> > 



-- 
abs IT Service GmbH
abs gruppe
Michael Wirz
Entwicklung

Landsberger Straße 57
82266 Stegen am Ammersee
Telefon: +49 (0)8143 999 43
Telefax: +49 (0)8143 999 49

Michael.Wirz@abs.de
www.eFonds24.de


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: how to suppress xsi:nil="true" attributes in xml text

Posted by "Samuel B. Quiring" <sb...@Cayuse.com>.
When I asked a similiar question back on 10/25,  I received this:
  ----- Original Message ----- 
  From: Cezar Andrei 
  To: user@xmlbeans.apache.org 
  Sent: Tuesday, October 25, 2005 2:12 PM
  Subject: RE: nilable and validate()


  There is an earlier discussion on this topic, please see:
   
  http://www.mail-archive.com/user@xmlbeans.apache.org/msg00512.html
   
  Cezar
which I found very helpful.  The bottom line I came up with is you have to test your data for null for each item that has minOccurs="0".  If it is null, then you do not want to set the value.  I'll be interested if you come up with a different answer.

-Sam


----- Original Message ----- 
From: "Michael Wirz" <mi...@abs.de>
To: <us...@xmlbeans.apache.org>
Sent: Wednesday, November 23, 2005 9:27 AM
Subject: how to suppress xsi:nil="true" attributes in xml text


> Hello XML Beans Users,
> 
> I am using xmlBeans to create xml Documents. As usual I call all the setters
> of the elements and do a .xmlText(XmlOptions) or a .save(XmlOptions).
> Wherever I had passed null to the setter methods I find a xsi:nil="true"
> attribute, e.g. <Ort xsi:nil="true"></Ort>
> 
> First question: Why does that happen?
> Second question: How can I suppress this behaviour?
> I didnt find any option in Xmloptions that looked like it was it.
> 
> Thanks for your help,
> Michael Wirz
> 
> -- 
> abs IT Service GmbH
> abs gruppe
> Michael Wirz
> Entwicklung
> 
> Landsberger Straße 57
> 82266 Stegen am Ammersee
> Telefon: +49 (0)8143 999 43
> Telefax: +49 (0)8143 999 49
> 
> Michael.Wirz@abs.de
> www.eFonds24.de
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
>