Hi Alain, JiBX 1.2 does not support xsi:type. I thought this was discussed in the documentation, but I'm not finding it now that I look for that. I'll add a Schema Compatibility page back into the next build to cover this issue and some other less-significant issues.
I am working on adding xsi:type support for JiBX 2.0, but that's been delayed so many times I can't advise you to wait for it. If you need the xsi:type support you're currently better off working with another data binding approach, such as JAXB. - Dennis Dennis M. Sosnoski XML and Web Services in Java Training and Consulting http://www.sosnoski.com - http://www.sosnoski.co.nz Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117 Alain Tamayo wrote: > 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 > <http://jibx.org/starter%7DcontainerElement>" end tag, found > "{http://jibx.org/starter}childElement > <http://jibx.org/starter%7DchildElement>" 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® 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 > [email protected] > https://lists.sourceforge.net/lists/listinfo/jibx-users > ------------------------------------------------------------------------------ Download Intel® 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 [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users
