이전에 정렬 한 XML을 비 정렬 화하려고합니다.JAXB Unmarshal - 요소가 누락되어 있고 요소가 순서대로 정렬되지 않았습니다.
비 정렬화된 결과에서 요소가 누락되었습니다. 그리고 얻는 요소가 입력 XML과 동일한 순서가 아닙니다. afterUnmarshal() 리스너를 만들었으므로 거기에 요소가 있지만 결과 Java 객체에는 표시되지 않습니다.
XSD는 (a 'fanout' 노드, 예를 들어, processSteps 다른 세트를 포함 할 수 있으므로 깊이 트리 (중첩 될 수있다))과 같이 구성된다 :
<xsd:element name="process">
<xsd:annotation>
<xsd:documentation>Integration Process</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<!-- more -->
<xsd:element name="itinerary" type="lwis:itineraryType"/>
<!-- more -->
</xsd:complexType>
</xsd:element>
<xsd:complexType name="itineraryType">
<xsd:sequence>
<xsd:element name="step" type="lwis:stepType"/>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="step" type="lwis:stepType"/>
<xsd:element name="fanout" type="lwis:fanoutType"/>
<xsd:element name="decision">
<xsd:complexType>
<!-- snip.. -->
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
내가 순서 가정 SAX 파서가 제공하지만 SAX 파서가 아무런 이유없이 순서를 변경한다고 상상할 수 없습니까? 현재 목록의 첫 번째 요소는 XML의 마지막 요소입니다. 목록의 두 번째 요소는 XML의 세 번째 요소입니다. 무작위로 보입니다.
어떤 도움을 주셔서 감사합니다!
시료 입력 :
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<process name="My.Process" description="My Process description" qualityOfService="AT_LEAST_ONCE" entryEndpoint="ENTRY.EP" xmlns="http://www.xxxxx.com/ns/yyyy">
<faultEndpoint endpoint_ref="EXIT.EP"/>
<rejectEndpoint endpoint_ref="EXIT.EP"/>
<itinerary>
<step name="Step 1" endpoint_ref="Step1.EP" type="SERVICE"/>
<step name="Step2-CBRStep" endpoint_ref="Step2.EP" type="SERVICE"/>
<decision name="Decision-nonameneeded">
<option name="op1">
<step name="Step 2A" endpoint_ref="Step2a.EP" type="SERVICE"/>
</option>
<option name="op2">
<step name="Step 2B" endpoint_ref="Step2a.EP" type="SERVICE"/>
</option>
</decision>
<step name="Step 3" endpoint_ref="Step3.EP" type="SERVICE"/>
<fanout name="Fan1">
<path>
<step name="Step4A" endpoint_ref="Step4A.EP" type="SERVICE"/>
</path>
<path>
<step name="Step4B" endpoint_ref="Step4B.EP" type="SERVICE"/>
<step name="Step5" endpoint_ref="Step5.EP" type="SERVICE"/>
</path>
</fanout>
<step name="Step6" endpoint_ref="Step6.EP" type="SERVICE"/>
</itinerary>
</process>
대상 :
Process Object has a field with itinerary of Type ItineraryType which:
step = StepType ("Step6" from XML)
stepOrFanoutOrDecision = ArrayList:
item 0: ItineraryType$Decision ("Decision-nonameneeded" from XML)
option 0: "op1" from XML
step: "Step 2A" from XML
option 1: "op2" from XML
step: "Step 2B" from XML
item 1: FanoutType ("Fan1" from XML)
path 0:
step: Step4A
path 1:
step: Step5
스텝 1, 스텝 2 및 스텝 CBRStep-4B 누락? , toString를 확장 해시 코드와 동일 : 내가 사용
[email protected][[email protected][endpointRef=Step6.EP, type=SERVICE, params=<null>, paramsRef=<null>, name=Step6, description=<null>], stepOrFanoutOrDecision={[email protected][option={[email protected][[email protected][endpointRef=Step2a.EP, type=SERVICE, params=<null>, paramsRef=<null>, name=Step 2A, description=<null>], stepOrFanoutOrDecision=<null>, name=op1],[email protected][[email protected][endpointRef=Step2a.EP, type=SERVICE, params=<null>, paramsRef=<null>, name=Step 2B, description=<null>], stepOrFanoutOrDecision=<null>, name=op2]}, name=Decision-nonameneeded, description=<null>],[email protected][path={[email protected][[email protected][endpointRef=Step4A.EP, type=SERVICE, params=<null>, paramsRef=<null>, name=Step4A, description=<null>], stepOrFanoutOrDecision=<null>, name=<null>],[email protected][[email protected][endpointRef=Step5.EP, type=SERVICE, params=<null>, paramsRef=<null>, name=Step5, description=<null>], stepOrFanoutOrDecision=<null>, name=<null>]}, name=Fan1, description=<null>]}]
개미 스크립트 :
는 여기 여정의 toString() 출력이
<?xml version="1.0" encoding="UTF-8"?>
<project name="RunningXjc" default="generate-sources" basedir=".">
<description>Runs Xjc Binding Compiler</description>
<target name="generate-sources">
<taskdef name="xjc" classname="org.jvnet.jaxb2_commons.xjc.XJC2Task">
<classpath>
<fileset dir="buildLib/jaxb-ri-2.2.6/lib">
<include name="*" />
</fileset>
<fileset dir="buildLib/jaxb2-basics-dist-0.6.4/dist">
<include name="jaxb2-basics-ant-*.jar" />
</fileset>
</classpath>
</taskdef>
<!-- Generate the Java code for XSD -->
<xjc destdir="${basedir}/target/generated-sources/xjc" extension="true">
<arg
line="
-Xequals
-XhashCode
-XtoString
-Xcopyable
-Xmergeable" />
<binding dir="${basedir}/src">
<include name="**/*.xjb" />
</binding>
<schema dir="${basedir}/schema">
<include name="processSlim.xsd" />
</schema>
<!-- Plugins -->
<classpath>
<fileset dir="${basedir}/buildLib/jaxb2-basics-dist-0.6.4">
<!-- JAXB2 Basics library -->
<include name="dist/jaxb2-basics-*.jar" />
<!-- JAXB2 Basics library dependencies -->
<include name="dist/jaxb2-basics-runtime-*.jar" />
<include name="dist/jaxb2-basics-tools-*.jar" />
<include name="lib/commons-beanutils-*.jar" />
<include name="lib/commons-lang-*.jar" />
<include name="lib/commons-logging-*.jar" />
<include name="lib/javaparser-*.jar" />
<include name="lib/annox-*.jar" />
</fileset>
</classpath>
</xjc>
</target>
</project>
해당 JAXB 객체는 어떻게 생겼습니까? –
추가 정보 추가 - 관심을 끌기를 바랬습니다 :) 블로그에서 일부 항목을 읽었지만 찾고있는 것을 찾을 수 없었습니다 .. – PhilW
XML 스키마에서 모델을 생성 했습니까? –