[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-user
Subject:    =?iso-8859-1?Q?RE=3A_R=E9f=2E_=3A_RE=3A_Problem_with_boolean_type?=
From:       "Cezar Andrei" <cezar () bea ! com>
Date:       2007-10-10 18:42:51
Message-ID: BF6B6CA032BA0A429BD924F96765147D4CD98F () repbex02 ! amer ! bea ! com
[Download RAW message or body]

It is not a bug, as Dennis said in a previous email, XMLBeans and binding tools in \
general, try to do the right thing in many cases, but this is not one of them. Even \
if this Boolean restriction seems simple enough, to support all restrictions is \
impossible.

 

Check out the following example on how to use 0/1 instead of true/false for a Boolean \
type:

 

        XmlBoolean xb = XmlBoolean.Factory.newInstance();

        xb.setStringValue("1");

 

 

        XmlObject xo = XmlObject.Factory.parse("<a/>");

        System.out.println("  xo: "  + xo);

 

        XmlObject axo = xo.selectChildren("", "a")[0];

 

        axo.set(xb);

 

        System.out.println("  xo: "  + xo);

 

Cezar

 

 

________________________________

From: Wing Yew Poon [mailto:wpoon@bea.com] 
Sent: Wednesday, October 10, 2007 1:27 PM
To: user@xmlbeans.apache.org
Subject: RE: Réf. : RE: Problem with boolean type

 

Then that is a bug. You can file a bug in JIRA.

 

________________________________

From: valerie.bauche@bull.net [mailto:valerie.bauche@bull.net] 
Sent: Wednesday, October 10, 2007 2:16 AM
To: user@xmlbeans.apache.org
Subject: Réf. : RE: Problem with boolean type



Yes I get mustUnderstand="true" instead of mustUnderstand="1" 

Valerie 



 

"Wing Yew Poon" <wpoon@bea.com> 

09/10/2007 21:40 
Veuillez répondre à user 

        
        Pour :        <user@xmlbeans.apache.org> 
        cc :         
        Objet :        RE: Problem with boolean type



Valerie, 
what exactly is the incorrect behavior you are seeing? 
Are you saying that the xml that is marshalled is incorrect after calling the setter? \
i.e., you call setMustUnderstand(true) and the xml shows mustUnderstand="true" \
                instead of mustUnderstand="1"? 
- Wing Yew 

________________________________

From: valerie.bauche@bull.net [mailto:valerie.bauche@bull.net] 
Sent: Tuesday, October 09, 2007 6:53 AM
To: user@xmlbeans.apache.org
Subject: Problem with boolean type



I have the following schema element : 

 <xs:attribute name="mustUnderstand">         
    <xs:simpleType> 
             <xs:restriction base="xs:boolean"> 
          <xs:pattern value="0|1"/> 
        </xs:restriction> 
    </xs:simpleType> 
 </xs:attribute> 

Xbean generates the following accessors : 
   void setMustUnderstand(boolean mustUnderstand); 
   boolean getMustUnderstand(); 

This result in an xml attribute with value "true" or "false" : it is not correct \
regarding the schema ! 

Is there anything to do to correct it? 

Notice: This email message, together with any attachments, may contain information of \
BEA Systems, Inc., its subsidiaries and affiliated entities, that may be \
confidential, proprietary, copyrighted and/or legally privileged, and is intended \
solely for the use of the individual or entity named in this message. If you are not \
the intended recipient, and have received this message in error, please immediately \
return this by email and then delete it. 


Notice: This email message, together with any attachments, may contain information of \
BEA Systems, Inc., its subsidiaries and affiliated entities, that may be \
confidential, proprietary, copyrighted and/or legally privileged, and is intended \
solely for the use of the individual or entity named in this message. If you are not \
the intended recipient, and have received this message in error, please immediately \
return this by email and then delete it.

Notice:  This email message, together with any attachments, may contain information  \
of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be \
confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended \
solely for the use of the individual or entity named in this message. If you are not \
the intended recipient, and have received this message in error, please immediately \
return this by email and then delete it.


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:st1="urn:schemas-microsoft-com:office:smarttags" \
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:sans-serif;
	panose-1:0 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
p
	{mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman";}
span.EmailStyle18
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>It is not a bug, as Dennis said in a
previous email, XMLBeans and binding tools in general, try to do the right
thing in many cases, but this is not one of them. Even if this Boolean restriction
seems simple enough, to support all restrictions is \
impossible.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Check out the following example on how to use
0/1 instead of true/false for a Boolean type:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>        XmlBoolean xb =
XmlBoolean.Factory.newInstance();<o:p></o:p></span></font></p>

<p class=MsoNormal><b><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy;font-weight:bold'>       
xb.setStringValue(&quot;1&quot;);<o:p></o:p></span></font></b></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>        XmlObject xo =
XmlObject.Factory.parse(&quot;&lt;a/&gt;&quot;);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>        System.out.println(&quot;  xo:
&quot;  + xo);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>        XmlObject axo =
xo.selectChildren(&quot;&quot;, &quot;a&quot;)[0];<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>        <b><span \
style='font-weight:bold'>axo.set(xb);<o:p></o:p></span></b></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>        System.out.println(&quot;  xo:
&quot;  + xo);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Cezar<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> <st1:PersonName
w:st="on">Wing Yew Poon</st1:PersonName> [mailto:wpoon@bea.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, October 10, 2007
1:27 PM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName \
w:st="on">user@xmlbeans.apache.org</st1:PersonName><br> <b><span \
style='font-weight:bold'>Subject:</span></b> RE: Réf. : RE: Problem with boolean \
type</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=blue face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:blue'>Then that is a bug. You can file a bug in
JIRA.</span></font><o:p></o:p></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabIndex=-1>

</span></font></div>

<p class=MsoNormal style='margin-bottom:12.0pt'><b><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>From:</span></font></b><font
 size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
valerie.bauche@bull.net [mailto:valerie.bauche@bull.net] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, October 10, 2007
2:16 AM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName \
w:st="on">user@xmlbeans.apache.org</st1:PersonName><br> <b><span \
style='font-weight:bold'>Subject:</span></b> Réf. : RE: Problem with boolean \
type</span></font><o:p></o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'><br>
</span></font><font size=2 face=sans-serif><span style='font-size:10.0pt;
font-family:sans-serif'><br>
Yes I get </span></font><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>mustUnderstand=&quot;true&quot; instead of
mustUnderstand=&quot;1&quot;</span></font> <br>
<br>
<font size=2 face=sans-serif><span \
style='font-size:10.0pt;font-family:sans-serif'>Valerie</span></font> <br>
<br>
<o:p></o:p></p>

<table class=MsoNormalTable border=0 cellpadding=0 width="100%"
 style='width:100.0%'>
 <tr>
  <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  <p class=MsoNormal><font size=3 face="Times New Roman"><span
  style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>
  </td>
  <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  <p class=MsoNormal><b><font size=1 face=sans-serif><span style='font-size:
  7.5pt;font-family:sans-serif;font-weight:bold'>&quot;<st1:PersonName w:st="on">Wing
   Yew Poon</st1:PersonName>&quot; &lt;wpoon@bea.com&gt;</span></font></b> \
<o:p></o:p></p>  <p><font size=1 face=sans-serif><span \
style='font-size:7.5pt;font-family:  sans-serif'>09/10/2007 21:40</span></font> <br>
  <font size=1 face=sans-serif><span \
style='font-size:7.5pt;font-family:sans-serif'>Veuillez  répondre à \
user</span></font> <o:p></o:p></p>  </td>
  <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
  <p class=MsoNormal><font size=1 face=Arial><span style='font-size:7.5pt;
  font-family:Arial'>&nbsp; &nbsp; &nbsp; &nbsp; </span></font><br>
  <font size=1 face=sans-serif><span \
style='font-size:7.5pt;font-family:sans-serif'>&nbsp;  &nbsp; &nbsp; &nbsp; Pour : \
&nbsp; &nbsp; &nbsp; &nbsp;&lt;<st1:PersonName  \
w:st="on">user@xmlbeans.apache.org</st1:PersonName>&gt;</span></font> <br>  <font \
size=1 face=sans-serif><span style='font-size:7.5pt;font-family:sans-serif'>&nbsp;  \
&nbsp; &nbsp; &nbsp; cc : &nbsp; &nbsp; &nbsp; &nbsp;</span></font> <br>  <font \
size=1 face=sans-serif><span style='font-size:7.5pt;font-family:sans-serif'>&nbsp;  \
&nbsp; &nbsp; &nbsp; Objet : &nbsp; &nbsp; &nbsp; &nbsp;RE: Problem with  boolean \
type</span></font><o:p></o:p></p>  </td>
 </tr>
</table>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
<br>
</span></font><font size=2 color=blue face=Arial><span style='font-size:10.0pt;
font-family:Arial;color:blue'>Valerie,</span></font> <br>
<font size=2 color=blue face=Arial><span style='font-size:10.0pt;font-family:
Arial;color:blue'>what exactly is the incorrect behavior you are \
seeing?</span></font> <br>
<font size=2 color=blue face=Arial><span style='font-size:10.0pt;font-family:
Arial;color:blue'>Are you saying that the xml that is marshalled is incorrect
after calling the setter? i.e., you call setMustUnderstand(true) and the xml
shows mustUnderstand=&quot;true&quot; instead of \
mustUnderstand=&quot;1&quot;?</span></font> <br>
<font size=2 color=blue face=Arial><span style='font-size:10.0pt;font-family:
Arial;color:blue'>- Wing Yew</span></font> <o:p></o:p></p>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p class=MsoNormal style='margin-bottom:12.0pt'><b><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>From:</span></font></b><font
 size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
valerie.bauche@bull.net [mailto:valerie.bauche@bull.net] <b><span
style='font-weight:bold'><br>
Sent:</span></b> Tuesday, October 09, 2007 6:53 AM<b><span style='font-weight:
bold'><br>
To:</span></b> <st1:PersonName \
w:st="on">user@xmlbeans.apache.org</st1:PersonName><b><span \
style='font-weight:bold'><br> Subject:</span></b> Problem with boolean \
type</span></font><br> <br>
<font size=2 face=sans-serif><span \
style='font-size:10.0pt;font-family:sans-serif'><br> <br>
I have the following schema element : </span></font><br>
<font size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier \
New"'><br> &nbsp;<font color=teal><span style='color:teal'>&lt;</span></font><font
color="#3f8080"><span style='color:#3F8080'>xs:attribute </span></font><font
color=purple><span style='color:purple'>name</span></font>=<font \
color="#4200ff"><span \
style='color:#4200FF'>&quot;mustUnderstand&quot;</span></font><font color=teal><span \
style='color:teal'>&gt;</span></font> &nbsp; &nbsp; &nbsp; &nbsp;</span></font> <font \
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier \
New"'><br> &nbsp; &nbsp; <font color=teal><span \
style='color:teal'>&lt;</span></font><font color="#3f8080"><span \
style='color:#3F8080'>xs:simpleType</span></font><font color=teal><span \
style='color:teal'>&gt;</span></font></span></font> <font size=2 face="Courier \
New"><span style='font-size:10.0pt;font-family:"Courier New"'><br> &nbsp; &nbsp; \
<font color=teal><span style='color:teal'>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;&lt;</span></font><font color="#3f8080"><span \
style='color:#3F8080'>xs:restriction </span></font><font color=purple><span \
style='color:purple'>base</span></font>=<font color="#4200ff"><span \
style='color:#4200FF'>&quot;xs:boolean&quot;</span></font><font color=teal><span \
style='color:teal'>&gt;</span></font></span></font> <font size=2 face="Courier \
New"><span style='font-size:10.0pt;font-family:"Courier New"'><br> &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; <font color=teal><span \
style='color:teal'>&lt;</span></font><font color="#3f8080"><span \
style='color:#3F8080'>xs:pattern </span></font><font color=purple><span \
style='color:purple'>value</span></font>=<font color="#4200ff"><span \
style='color:#4200FF'>&quot;0|1&quot;</span></font><font color=teal><span \
style='color:teal'>/&gt;</span></font></span></font> <font size=2 face="Courier \
New"><span style='font-size:10.0pt;font-family:"Courier New"'><br> &nbsp; &nbsp; \
&nbsp; &nbsp; <font color=teal><span style='color:teal'>&lt;/</span></font><font \
color="#3f8080"><span style='color:#3F8080'>xs:restriction</span></font><font \
color=teal><span style='color:teal'>&gt;</span></font></span></font> <font size=2 \
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br> \
&nbsp; &nbsp; <font color=teal><span style='color:teal'>&lt;/</span></font><font \
color="#3f8080"><span style='color:#3F8080'>xs:simpleType</span></font><font \
color=teal><span style='color:teal'>&gt;</span></font></span></font> <font size=2 \
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br> \
&nbsp;<font color=teal><span style='color:teal'>&lt;/</span></font><font \
color="#3f8080"><span style='color:#3F8080'>xs:attribute</span></font><font \
color=teal><span style='color:teal'>&gt;</span></font></span></font> <br> <font \
size=2 face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'><br> \
Xbean generates the following accessors : </span></font><font size=2 face="Courier \
New"><span style='font-size:10.0pt;font-family:"Courier New"'><br> &nbsp; \
&nbsp;<b><font color="#820040"><span style='color:#820040;font-weight: \
bold'>void</span></font></b> setMustUnderstand(<b><font color="#820040"><span \
style='color:#820040;font-weight:bold'>boolean</span></font></b> \
mustUnderstand);</span></font> <font size=2 face="Courier New"><span \
style='font-size:10.0pt;font-family:"Courier New"'><br> &nbsp; &nbsp;<b><font \
color="#820040"><span style='color:#820040;font-weight: \
bold'>boolean</span></font></b> getMustUnderstand();</span></font> <br> <font size=2 \
face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'><br> This \
result in an xml attribute with value &quot;true&quot; or &quot;false&quot; : it is \
not correct regarding the schema !</span></font> <br> <font size=2 \
face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'><br> Is there \
anything to do to correct it?</span></font> <br> <br>
Notice: This email message, together with any attachments, may contain
information of BEA Systems, Inc., its subsidiaries and affiliated entities,
that may be confidential, proprietary, copyrighted and/or legally privileged,
and is intended solely for the use of the individual or entity named in this
message. If you are not the intended recipient, and have received this message
in error, please immediately return this by email and then delete it. <o:p></o:p></p>

</div>

</div>

</body>

</html>
<br>
Notice:  This email message, together with any attachments, may contain information  \
of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be \
confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended \
solely for the use of the individual or entity named in this message. If you are not \
the intended recipient, and have received this message in error, please immediately \
                return this by email and then delete it.<br>
Notice:  This email message, together with any attachments, may contain information  \
of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be \
confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended \
solely for the use of the individual or entity named in this message. If you are not \
the intended recipient, and have received this message in error, please immediately \
return this by email and then delete it.



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic