Hello jibx-users,

I cannot unmarshal my beans. I have 4 beans:

TestDAO - object inherited from LightTestDAO that contains
        LightQuestionDAO array
LightTestDAO - object inherited from BasicDAO
LightQuestionDAO - object inherited from BasicDAO
BasicDAO - superclass of all beans

  Here is my binding file. It is generated by Jibx binding generator.
  
<?xml version="1.0" encoding="UTF-8"?>
<binding forwards="false" value-style="attribute">
  <mapping class="com.magic.testframework.service.dao.LightTestDAO" 
name="light-test-dao">
    <structure map-as="com.magic.testframework.service.dao.BasicDAO"/>
    <value style="element" name="name" field="name" usage="optional"/>
  </mapping>
  <mapping class="com.magic.testframework.service.dao.LightQuestionDAO" 
name="light-question-dao">
    <value style="element" name="question" field="question" usage="optional"/>
    <value style="element" name="question-uid" field="questionUID" 
usage="optional"/>
    <structure map-as="com.magic.testframework.service.dao.BasicDAO"/>
  </mapping>
  <mapping class="com.magic.testframework.service.dao.BasicDAO" 
name="basic-dao">
    <value name="id" field="id"/>
  </mapping>
  <mapping class="com.magic.testframework.service.dao.TestDAO" name="test-dao">
    <structure field="questions" usage="optional" 
marshaller="org.jibx.extras.TypedArrayMapper" 
unmarshaller="org.jibx.extras.TypedArrayMapper"/>
    <structure map-as="com.magic.testframework.service.dao.LightTestDAO"/>
  </mapping>
</binding>
  
I try to marshal TestDAO object that contains 2 LightQuestionDAO
objects. Here is my code to marshal and unmarshal bean:

    IBindingFactory bfact = BindingDirectory.getFactory(TestDAO.class);
    IMarshallingContext mctx = bfact.createMarshallingContext();
    mctx.setIndent(2);
    mctx.marshalDocument(test, "UTF-8", null, out);

    // unmarshal customer information from file
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    FileInputStream in = new FileInputStream("out.xml");
    TestDAO customer = (TestDAO) uctx.unmarshalDocument(in, null);
    // marshal object back out to file (with nice indentation, as UTF-8)

This is exception I get:

org.jibx.runtime.JiBXException: Expected "light-test-dao" start tag, found 
"light-question-dao" start tag (line 3, col 23)
        at 
org.jibx.runtime.impl.UnmarshallingContext.throwStartTagNameError(UnmarshallingContext.java:287)
        at 
org.jibx.runtime.impl.UnmarshallingContext.matchStart(UnmarshallingContext.java:707)
        at 
org.jibx.runtime.impl.UnmarshallingContext.parsePastStartTag(UnmarshallingContext.java:743)
        at

this is the result xml data file:

<test-dao>
  <light-question-dao>
    <question>0.13989470240018909sdfhsdjfhgjshgdfg sjhdgfjhsgd fjdshgf jhsg dfh 
sd</question>
    <basic-dao id="0"/>
  </light-question-dao>
  <light-question-dao>
    <question>0.1210021595849744sdfhsdjfhgjshgdfg sjhdgfjhsgd fjdshgf jhsg dfh 
sd</question>
    <basic-dao id="0"/>
  </light-question-dao>
  <light-test-dao>
    <name>test0.5846512745507241</name>
    <basic-dao id="0"/>
  </light-test-dao>
</test-dao>
        
What am I doing wrong? How should I unmarshal these files? Please,
help.
        
-- 
Best regards,
 wizzy                          mailto:[EMAIL PROTECTED]


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to