JAXB data binding .boolean type

[size=18]i try to use JAXB to binding the XML data to class. and i met some question that really boring. :twisted:

the key of the question is : when i use the JAXB to get the xml data. the boolean data which in the in the created object is not correct.
here are my dtd file and xml file.[/size]
[size=18][color=yellow]conditions.dtd :[/color][/size]
<!ELEMENT conditions (condition*)>
<!ELEMENT condition (entrytype,type,leastNum,auto,unit,originate,last) >
<!ELEMENT entrytype (#PCDATA)>
<!ELEMENT type (#PCDATA)>
<!ELEMENT originate (#PCDATA)>
<!ELEMENT auto (#PCDATA)>
<!ELEMENT unit (#PCDATA)>
<!ELEMENT leastNum (#PCDATA)>
<!ELEMENT last (#PCDATA)>
<!ATTLIST condition isInfoComplete CDATA "true">

[size=24][color=yellow]conditions.xml :[/color][/size]
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE conditions SYSTEM "conditions.dtd"><conditions>
<condition isInfoComplete="true">
<entrytype>blogentry</entrytype>
<type>apply</type>
<leastNum>3</leastNum>
<auto>true</auto>
<unit>week</unit>
<originate>true</originate>
<last>y</last>
</condition>
<condition isInfoComplete="true'">
<entrytype>blogentry</entrytype>
<type>keep</type>
<leastNum>20</leastNum>
<auto>true</auto>
<unit>month</unit>
<originate>false</originate>
<last>m</last>
</condition>
</conditions>


the class file is generated by the JAXB tool. and follow is my test class. notice the pakage path.
CollectionTest.java:public class ConditionTest {
public static void main(String[] args) {
try {
JAXBContext jc = JAXBContext.newInstance("test.xmlparse");
Unmarshaller u = jc.createUnmarshaller();
Conditions conds = (Conditions) u.unmarshal(new FileInputStream(
new File("conditions.xml")));
List cond=conds.getCondition();
int size = cond.size();
for(int i=0;i<size;i++) {
Condition con=(Condition) cond.get(i);
print(con);
}
System.out.println(conds.getCondition().size());
} catch (Exception ex) {
System.out.println(ex.getMessage());
System.out.println(ex.getCause());
}
}

private static void print(Condition con) {
System.out.println("auto:"+con.getAuto()+"\nlast:"+con.getLast()+"\nentrytype:"+con.getEntrytype()+"\ntype:"+
con.getType()+"\nunit:"+con.getUnit()+"\nisInfoComplete:"+con.getisInfoComplete()+
"\nleastNum:"+con.getLeastNum()+"\noriginate:"+con.getOriginate()+"\n\n\n");
}
}


here is my result:
auto:true
last:y
entrytype:blogentry
type:apply
unit:week
isInfoComplete:[color=red]false[/color]
leastNum:3
originate:true


auto:true
last:m
entrytype:blogentry
type:keep
unit:month
isInfoComplete:[color=red]false[/color]
leastNum:20
originate:false
-----------------------------------------------------------------------
[color=blue][size=18]i tracked the program. the value of isInfoComplete have get when the object created.but the value is not correct.[/size][/color]:twisted: :arrow:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值