2011-02-08 4 views
2

사용자 정의 JiBX 마샬 러를 생성하고 작동하는지 확인했습니다. 그것은 다음과 같은 일을함으로써 작동합니다 :사용자 정의 JiBX 마샬 러와의 추상 매핑

<binding xmlns:tns="http://foobar.com/foo" direction="output"> 
    <namespace uri="http://foobar.com/foo" default="elements"/> 
    <mapping class="java.util.HashMap" marshaller="com.foobar.Marshaller1"/> 
    <mapping name="context" class="com.foobar.Context"> 
    <structure field="configuration"/> 
    </mapping> 
</binding> 

그러나 다른 HashMaps에 대해 여러 마샬 러를 생성해야합니다. 나는 다음과 같은 수신 바인딩을 구축 할 때, 이렇게 그러나

<binding xmlns:tns="http://foobar.com/foo" direction="output"> 
    <namespace uri="http://foobar.com/foo" default="elements"/> 
    <mapping abstract="true" type-name="configuration" class="java.util.HashMap" marshaller="com.foobar.Marshaller1"/> 
    <mapping abstract="true" type-name="overrides" class="java.util.HashMap" marshaller="com.foobar.Marshaller2"/> 
    <mapping name="context" class="com.foobar.Context"> 
    <structure map-as="configuration" field="configuration"/> 
    <structure map-as="overrides" field="overrides"/> 
    </mapping> 
</binding> 

: 그래서 나는이 같은 추상적 인 매핑을 참조하려고

Error during code generation for file "E:\project\src\main\jibx\foo.jibx" - this may be due to an error in your binding or classpath, or to an error in the JiBX code 

내 생각이 있다는 것입니다 I 중 하나 추상 매핑을 위해 내 맞춤 마샬 러를 사용하도록 구현해야하는 항목이 누락되었거나 맞춤 마샬 러가 추상 매핑을 지원하지 않습니다.

JiBX API (http://jibx.sourceforge.net/api/org/jibx/runtime/IAbstractMarshaller.html)에서 IAbstractMarshaller 인터페이스를 찾았지만 구현해야하는 경우 문서가 명확하지 않은 것처럼 보입니다. 이 인터페이스의 구현을 찾아보기 위해 예제로 작동하지 못했습니다.

제 질문은 사용자 지정 마샬 러 (가능한 경우)와 어떻게 추상적 매핑을 수행합니까? IAbstractMarshaller 인터페이스를 통해 수행되면 어떻게 작동하고 구현해야합니까?

답변

2

IAbstractMarshaller 인터페이스가 당신이 찾고있는 것인지 확실하지 않습니다. 워드 프로세서는 약간 불분명하다. 약간의 반복을 염두에 두지 않는다면 구조 매핑에서 직접 마샬 러를 지정할 수 있습니다. 원하는 결과를 얻을 수 있습니다 ('구성'및 '재정의'에 대한 별도의 매핑).

<binding xmlns:tns="http://foobar.com/foo" direction="output"> 
    <namespace uri="http://foobar.com/foo" default="elements"/> 
    <mapping name="context" class="com.foobar.Context"> 
    <structure map-as="configuration" field="configuration" marshaller="com.foobar.Marshaller1"/> 
    <structure map-as="overrides" field="overrides" marshaller="com.foobar.Marshaller2"/> 
    </mapping> 
</binding> 
관련 문제