hello,all
as a new jaxb user ,i have the below prolbem,looking for help.
i use xjc to generated the java files and use jaxb Unmarshaller xml to
object, but i can't get all the Unmarshaller objects.
that's is to say i can get the tag {"searchRequest" ,
"query","type1","rpn","rpnRpnOp","rpn1"} representation object. but i can
not get searchRequest>query>type1>rpn>rpnRpnOp>rpn1>rpnRpnOp the last
object rpnRpnOp is null !!!
the related file and codes as below,
1 polan.xml
<?xml version="1.0" encoding="GBK"?>
<searchRequest xmlns="urn:com:zhjy:mltx:egss:1.0">
<referenceId>123</referenceId>
<query>
<type1>
<attributeSet>政务信息资源目录服务属性集</attributeSet>
<rpn>
<rpnRpnOp>
<rpn1>
<rpnRpnOp>
<rpn1>
<op>
<attrTerm>
<attributes>
<attributeElement>
<attributeType>1</attributeType>
<attributeValue>1.001</attributeValue>
</attributeElement>
<attributeElement>
<attributeType>2</attributeType>
<attributeValue>3</attributeValue>
</attributeElement>
</attributes>
<term>
<characterString>restriction:1</characterString>
</term>
</attrTerm>
</op>
</rpn1>
<rpn2>
<op>
<attrTerm>
<attributes>
<attributeElement>
<attributeType>1</attributeType>
<attributeValue>1.003</attributeValue>
</attributeElement>
<attributeElement>
<attributeType>2</attributeType>
<attributeValue>3</attributeValue>
</attributeElement>
</attributes>
<term>
<characterString>restriction:2</characterString>
</term>
</attrTerm>
</op>
</rpn2>
<operator>
<OR/>
</operator>
</rpnRpnOp>
</rpn1>
<rpn2>
<op>
<attrTerm>
<attributes>
<attributeElement>
<attributeType>1</attributeType>
<attributeValue>1.002</attributeValue>
</attributeElement>
<attributeElement>
<attributeType>2</attributeType>
<attributeValue>2</attributeValue>
</attributeElement>
</attributes>
<term>
<characterString>2002-01-01</characterString>
</term>
</attrTerm>
</op>
</rpn2>
<operator>
<and/>
</operator>
</rpnRpnOp>
</rpn>
</type1>
</query>
<otherInfo>test</otherInfo>
</searchRequest>
2 the polan.xsd
.....
<xs:complexType name="searchRequestType">
<xs:annotation>
<xs:documentation>检索请求的类型定义。</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element ref="referenceId" />
<xs:element name="replaceIndicator" type="xs:boolean" />
<xs:element name="resultSetID" type="xs:string" />
<xs:element ref="databaseNames" />
<xs:element name="preferredRecordSyntax" type="xs:string"
default="XML" minOccurs="0" />
<!-- preferredRecordSyntax表示查询结果的编码方式。默认采用XML方式 -->
<xs:element ref="query" />
<xs:element ref="otherInfo" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<!-- 类型标识符"Query"的定义 -->
<xs:element name="query" type="queryType" />
<xs:complexType name="queryType">
<xs:choice>
<xs:element name="type1">
<xs:annotation>
<xs:documentation>检索串的类型是type-1</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="attributeSet" type="xs:string"
fixed="政务信息资源目录服务属性集" />
<xs:element name="rpn" type="RPNQueryType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<!-- 类型标识符"RPNQueryType"的定义 -->
<xs:complexType name="RPNQueryType">
<xs:annotation>
<xs:documentation>逆波兰检索表达式。</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:element name="op" type="ArgumentType" />
<xs:element name="rpnRpnOp" type="ComplexArugmentType" />
</xs:choice>
</xs:complexType>
<xs:complexType name="ArgumentType">
<xs:choice>
<xs:element name="attrTerm" type="operandType" />
<xs:element name="rpn" type="RPNQueryType" />
</xs:choice>
</xs:complexType>
<xs:complexType name="ComplexArugmentType">
<xs:sequence>
<xs:element name="rpn1" type="ArgumentType" />
<xs:element name="rpn2" type="ArgumentType" />
<xs:element name="operator" type="operatorType" />
</xs:sequence>
</xs:complexType>
<!-- 类型标识符"RPNStructure"的定义 -->
<xs:element name="RPNStructure" type="RPNStructureType" />
<xs:complexType name="RPNStructureType">
<xs:choice>
<xs:element name="operand" type="operandType" />
<xs:element name="rpnRpnOp">
<xs:complexType>
<xs:sequence>
<xs:element name="operator" type="operatorType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<!-- 类型标识符"Operand"的定义 -->
<xs:element name="operand" type="operandType">
<xs:annotation>
<xs:documentation>操作数。</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="operandType">
<xs:annotation>
<xs:documentation>操作数的类型定义。</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="attributes" type="attributeList" />
<xs:element name="term" type="termType" />
</xs:sequence>
</xs:complexType>
<!-- 类型标识符"attributeList"的定义 -->
<xs:complexType name="attributeList">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="attributeElement">
<xs:complexType>
<xs:sequence>
<xs:element name="attributeType" type="xs:integer"/>
<xs:element name="attributeValue" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- 类型标识符"Term"的定义 -->
<xs:complexType name="termType">
<xs:choice>
<xs:element name="general" type="xs:hexBinary" />
<xs:element name="numeric" type="xs:integer" />
<xs:element name="characterString" type="xs:string" />
<xs:element name="recordId" type="xs:string" />
<xs:element name="dateTime" type="generalizedTimeType" />
</xs:choice>
</xs:complexType>
<!-- 类型标识符"Operator"的定义 -->
<xs:element name="operator" type="operatorType">
<xs:annotation>
<xs:documentation>操作符。</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="operatorType">
<xs:annotation>
<xs:documentation>操作符的类型定义。</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:element name="and" type="NullType" />
<xs:element name="or" type="NullType" />
<xs:element name="not" type="NullType" />
</xs:choice>
</xs:complexType>
<xs:complexType name="NullType">
<xs:annotation>
<xs:documentation>抽象类型。表示元素出现即可,没有取值。</xs:documentation>
</xs:annotation>
</xs:complexType>
......
3 i use xjc generate java code success from the xsd.
4 i use below code to Unmarshaller the polan.xml
JAXBContext jc = JAXBContext.newInstance("com.zhjy.mltx.egss");
Unmarshaller u = jc.createUnmarshaller();
JAXBElement customerE = (JAXBElement) u.unmarshal(new FileInputStream(
"c:/test_polan1.xml"));
SearchRequestType srt = (SearchRequestType) customerE.getValue();
QueryType queryType= srt.getQuery();
System.out.println("=============query============");
System.out.println(ToStringBuilder.reflectionToString(queryType));
System.out.println("===============type1==========");
Type1 type1 = queryType.getType1();
System.out.println(ToStringBuilder.reflectionToString(type1));
System.out.println("==============rpn===========");
RPNQueryType rpn0 = type1.getRpn();
ComplexArugmentType cat = rpn0.getRpnRpnOp();
ArgumentType at1= cat.getRpn1();
ArgumentType at2 = cat.getRpn2();
OperatorType ot = cat.getOperator();
RPNQueryType rpn1 = at1.getRpn(); //-----this line get null
ArgumentType at11 = rpn1.getOp(); //-----this line get null
is any where has error? please help me! thanks
--
View this message in context: http://www.nabble.com/maybe-a-cycle-error%21%21%21-please-give-help-tp14797294p14797294.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.