Anyone?  I really need to figure out what I am doing wrong with this.

Thanks.


reemo wrote:
> 
> Hi,
> 
> I have created my own custom IdDefRefMapperBase impl so that I can
> have IDREF's on my collection.  All the custom IdDefRefMapperBase is
> doing is generating the correct "id" for the references by overriding
> the getIdValue() .  This is working fine for "marshalling" the objects
> out but when I try to read the same XML back in for "un-marshalling" I
> always get this error pasted below.  You can see the marshalled xml
> (below) that is having the error AS WELL as the xml that is NOT.  You
> will notice in the XML output that is NOT having the issue, that the
> "<color/>" element is not present on the "<style/>" element.   There
> are ONLY <option> elements.
> 
> What it seems like is happening as that the collection's can't support
> IDREF's with mulitple object types in the collection?  Is this the
> case?
> 
> I have tried everyting and searched the mailing lists, JIRA, etc with
> no luck on this issue.  Please help!
> 
> Thanks in advance!
> 
> 
> -----------------
> Mapping file:
> ------------------
>     <mapping class="test.TestModelYear" name="modelYear">
>         <collection create-type="java.util.HashSet" field="styles"
> item-type="test.TestStyle"/>
> 
>         <collection name="features" field="features" usage="optional"
> create-type="java.util.HashSet"
>                     >
>             <structure name="option"
> marshaller="com.edmunds.vehicle.jibx.VdmIdRefMapper"
>                       
> unmarshaller="com.edmunds.vehicle.jibx.VdmIdRefMapper"/>
>         </collection>
>     </mapping>
> 
>     <mapping class="test.TestStyle" name="style">
>         <collection name="features" field="features" usage="optional"
> create-type="java.util.HashSet"
>                     >
>             <structure name="option"
> marshaller="com.edmunds.vehicle.jibx.VdmIdRefMapper"
>                       
> unmarshaller="com.edmunds.vehicle.jibx.VdmIdRefMapper"/>
>         </collection>
>     </mapping>
> 
>     <mapping class="test.TestOption" name="option" >
>         <value style="attribute" name="path" field="path" ident="def"/>
>         <value style="attribute" name="optionName" field="optionName"
> usage="optional"/>
> 
>     </mapping>
> 
>     <mapping class="test.TestColor" name="color">
>         <value style="attribute" name="path" field="path" ident="def"/>
>         <value style="attribute" name="color" field="color"
> usage="optional"/>
> 
>     </mapping>
> 
> -------------
> Test Case:
> --------------
> package com.edmunds.jibx;
> 
> import junit.framework.TestCase;
> import org.jibx.runtime.BindingDirectory;
> import org.jibx.runtime.IBindingFactory;
> import org.jibx.runtime.IMarshallingContext;
> import org.jibx.runtime.IUnmarshallingContext;
> import test.TestColor;
> import test.TestModelYear;
> import test.TestOption;
> import test.TestStyle;
> 
> import java.io.FileInputStream;
> import java.io.FileOutputStream;
> import java.util.HashSet;
> import java.util.Set;
> 
> 
> public class TestJibxMappings extends TestCase {
> 
>     private static final String TMP_SAMPLE_OUTPUT_XML_FILE =
> "/tmp/sample-output.xml";
> 
>     public TestModelYear generateObject() throws Exception {
> 
> 
>         TestModelYear modelYear = new TestModelYear();
>         TestStyle style = new TestStyle();
> 
>         TestOption option = new TestOption();
>         option.setPath("/feature/100");
>         option.setOptionName("Option 1");
>         TestOption option2 = new TestOption();
>         option2.setPath("/feature/101");
>         option2.setOptionName("Option 2");
>         TestColor color = new TestColor();
>         color.setPath("/feature/102");
>         color.setColor("Blue");
> 
>         Set features = new HashSet();
>         features.add(option);
>         features.add(option2);
>         features.add(color);
> 
>         modelYear.setFeatures(features);
> 
>         Set styles = new HashSet();
>         style.setFeatures(features);
> 
>         styles.add(style);
>         modelYear.setStyles(styles);
> 
>         return modelYear;
>     }
> 
> 
>     private void marshallToFile() throws Exception {
>         TestModelYear modelYear = generateObject();
>         IBindingFactory bindingFactory =
> BindingDirectory.getFactory(TestModelYear.class);
>         IMarshallingContext mctx =
> bindingFactory.createMarshallingContext();
>         mctx.setIndent(2);
> 
>         mctx.marshalDocument(modelYear, "UTF-8", null, new
> FileOutputStream(TMP_SAMPLE_OUTPUT_XML_FILE));
>     }
> 
> 
>     public void testUnmarshallObjectsFromFile() {
>         try {
>             marshallToFile();
>             IBindingFactory bindingFactory =
> BindingDirectory.getFactory(TestModelYear.class);
>             IUnmarshallingContext unmarshallCtx =
> bindingFactory.createUnmarshallingContext();
>             TestModelYear modelYear = (TestModelYear)
> unmarshallCtx.unmarshalDocument(new
> FileInputStream(TMP_SAMPLE_OUTPUT_XML_FILE), "UTF-8");
>             assert modelYear != null;
>         } catch (Exception e) {
>             e.printStackTrace();
>             assert false;
>         }
> 
>     }
> }
> 
> 
> ----------------------------
> XML WITH-OUT ERROR:
> ----------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <modelYear>
>   <style>
>     <features>
>       <option path="/feature/100" optionName="Option 1"/>
>       <option path="/feature/101" optionName="Option 2"/>
>     </features>
>   </style>
>   <features>
>     <option ref="/feature/100"/>
>     <option ref="/feature/101"/>
>   </features>
> </modelYear>
> 
> 
> ----------------------------
> XML WITH ERROR:
> ----------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <modelYear>
>   <style>
>     <features>
>       <option path="/feature/100" optionName="Option 1"/>
>       <option path="/feature/101" optionName="Option 2"/>
>       <color path="/feature/102" color="Blue"/> <!-- this is the color
> element causing issue that I want -->
>     </features>
>   </style>
>   <features>
>     <option ref="/feature/100"/>
>     <option ref="/feature/101"/>
>     <option ref="/feature/102"/> <!-- ref to color element above
> causing issue -->
>   </features>
> </modelYear>
> 
> ---------
> Error:
> ---------
> org.jibx.runtime.JiBXException: Expected "features" end tag, found
> "color" start tag (line 5, col 48)
>       at
> org.jibx.runtime.impl.UnmarshallingContext.parsePastCurrentEndTag(UnmarshallingContext.java:792)
>       at test.TestStyle.JiBX_test_jibx_unmarshal_1_0(TestStyle.java)
>       at test.JiBX_test_jibxTestStyle_access2.unmarshal()
>       at test.JiBX_MungeAdapter.JiBX_test_jibx_unmarshal_1_0()
>       at test.TestModelYear.JiBX_test_jibx_unmarshal_1_2(TestModelYear.java)
>       at test.JiBX_test_jibxTestModelYear_access2.unmarshal()
>       at
> org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2537)
>       at
> org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2680)
>       at
> com.edmunds.jibx.TestJibxMappings.testUnmarshallObjectsFromFile(TestJibxMappings.java:98)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:324)
>       at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
>       at org.testng.internal.Invoker.invokeMethod(Invoker.java:473)
>       at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:567)
>       at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:834)
>       at
> org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
>       at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
>       at org.testng.TestRunner.runWorkers(TestRunner.java:689)
>       at org.testng.TestRunner.privateRun(TestRunner.java:566)
>       at org.testng.TestRunner.run(TestRunner.java:466)
>       at org.testng.SuiteRunner.runTest(SuiteRunner.java:301)
>       at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:296)
>       at org.testng.SuiteRunner.privateRun(SuiteRunner.java:276)
>       at org.testng.SuiteRunner.run(SuiteRunner.java:191)
>       at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808)
>       at org.testng.TestNG.runSuitesLocally(TestNG.java:776)
>       at org.testng.TestNG.run(TestNG.java:701)
>       at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
>       at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Un-Marshalling-different-object-types-in-collection-using-custom-IdDefRefMapperBase-not-working-tp15238713p15250097.html
Sent from the jibx-users mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to