Hi,

I have generated jibx code starting from the following schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns:tns="
http://jibx.org/starter"; elementFormDefault="qualified"   targetNamespace="
http://jibx.org/starter";>

<xs:complexType name="base">
    <xs:sequence>
          <xs:element name="baseElement" type="xs:string" minOccurs="1"/>
    </xs:sequence>
    <xs:attribute type="xs:string" use="required" name="id"/>
 </xs:complexType>

 <xs:complexType name="child">
    <xs:complexContent>
<xs:extension base="tns:base">
<xs:sequence>
<xs:element name="childElement" type="xs:string"/>
</xs:sequence>
</xs:extension>
    </xs:complexContent>
 </xs:complexType>

 <xs:complexType name="containerType">
<xs:sequence>
<xs:element name="containerElement" type="tns:base"/>
</xs:sequence>
 </xs:complexType>

 <xs:element name="container" type="tns:containerType" />
</xs:schema>

And I'm trying to read  the following XML document:

<container xmlns="http://jibx.org/starter"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";>
  <containerElement id="15" xsi:type="child">
   <baseElement>12345678</baseElement>
                <childElement>Child value</childElement>
   </containerElement>
</container>

using the following code fragment:

IBindingFactory bfact = BindingDirectory.getFactory(ContainerType.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
FileInputStream in = new FileInputStream(args[0]);

ContainerType cont = (ContainerType) uctx.unmarshalDocument(in, null);

System.out.println(cont.getContainerType().getId());
System.out.println(cont.getContainerType().getBaseElement());

but I get the following exception:

     org.jibx.runtime.JiBXException: Expected "{
http://jibx.org/starter}containerElement"; end tag, found "{
http://jibx.org/starter}childElement"; start tag (line 4, col 31)
           at
org.jibx.runtime.impl.UnmarshallingContext.parsePastCurrentEndTag(UnmarshallingContext.java:736)
           at
org.jibx.starter.ContainerType.JiBX_binding_unmarshal_1_0(ContainerType.java)
           at org.jibx.starter.JiBX_bindingContainerType_access2.unmarshal()
           at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2762)
           at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2905)
          at org.jibx.starter.Test.main(Test.java:37)

It seems that the "dymamic" type of containerElement is not recognized by
JiBX. Isn't xsi:type supported?? or there is any mistake in my code or xml
files??

Thanks in advance,

Alain
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to