Hi Dennis,
Thank you! That was nothing like the syntax that we were using, so no
wonder it didn't work. I think we were using structures and map-as too
much. I should have posted on this newgroup earlier.
Thanks for all your help! :)
--Polly
On Feb 6, 2008 5:19 AM, Dennis Sosnoski <[EMAIL PROTECTED]> wrote:
> Hi Polly,
>
> A collection of instances of the interface would just be:
>
> <collection field="m_dvdList"
> item-type="com.sosnoski.ws.library.jibx2wsdl.hd.Dvd"
> create-type="java.util.ArrayList"/>
>
> though you could use a factory instead of a create-type.
>
> - Dennis
>
> Dennis M. Sosnoski
> SOA 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
>
>
>
> amphoras wrote:
> > Hi Dennis,
> >
> > Thank you very much for taking the time to respond. I studied the
> > example that you pointed out, and I finally found the mistake in my
> > mapping! I knew it had to be something small and silly. Turns out
> > that it was. I simply forgot the namespace attribute in my mapping.
> > It should be like this:
> >
> > <mapping ns="http://www.gmail.com/my" name="myHeader"
> > class="com.my.Header"
> > extends="org.standard.Header">
> > <structure map-as="Header"/>
> > <value name="employeeId" field="employeeId"
> > ns="http://www.gmail.com/my" />
> > </mapping>
> >
> > I have done some testing, and it finally looks like it's working!
> >
> > I have a follow up question though. I haven't seen any examples
> > combining schema group substitution with a collection. Using your
> > example, I need to have a List<Dvd>, which means it can contain
> > BluRayDvd or HdDvd objects. What is the syntax for this? I tried a
> > few things but keep getting binding errors.
> >
> > Thanks,
> > Polly
> >
> >
> > On Feb 4, 2008 1:10 AM, Dennis Sosnoski <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> > Hi Polly,
> >
> > The differences between the different types of <mapping>s, when
> > you use
> > an abstract vs. concrete, and when you reference using a type name
> > vs. a
> > class name, can all be confusing issues. The tutorial has some
> > discussion of this at
> > http://jibx.sourceforge.net/tutorial/binding-mappings.html but some
> > parts are not as clear as they could be because new features were
> > added
> > over time and I was too lazy (or busy, if you want to be
> > charitable) to
> > rewrite the tutorial.
> >
> > The Jibx2Wsdl code
> > (http://www.sosnoski.com/jibx-wiki/space/axis2-jibx/jibx2wsdl) has
> an
> > example (example4) which includes multiple layers of substitution
> > groups. The inheritance structure uses both interfaces and
> > subclassing,
> > with a base Item interface thats implemented by Book and Dvd, an
> IDvd
> > interface that extends Item and is implemented by another Dvd
> > class, and
> > several subclasses of the latter Dvd class. Here's part of the
> binding
> > generated for this:
> >
> > <mapping abstract="true"
> > extends="com.sosnoski.ws.library.jibx2wsdl.Item"
> > class="com.sosnoski.ws.library.jibx2wsdl.hd.IDvd" name="IDvd">
> > <structure map-as="tns:IDvd"/>
> > </mapping>
> > <mapping abstract="true" type-name="tns:dvd1"
> > class="com.sosnoski.ws.library.jibx2wsdl.hd.Dvd">
> > <structure map-as="tns:IDvd"/>
> > </mapping>
> > <mapping abstract="true"
> > extends="com.sosnoski.ws.library.jibx2wsdl.hd.IDvd"
> > class="com.sosnoski.ws.library.jibx2wsdl.hd.Dvd" name="dvd1">
> > <structure map-as="tns:dvd1"/>
> > </mapping>
> > <mapping extends="com.sosnoski.ws.library.jibx2wsdl.hd.Dvd"
> > class="com.sosnoski.ws.library.jibx2wsdl.hd.HdDvd" name="hdDvd">
> > <structure map-as="tns:dvd1"/>
> > <value style="element" name="studio" get-method="getStudio"
> > set-method="setStudio" usage="optional"/>
> > </mapping>
> > <mapping extends="com.sosnoski.ws.library.jibx2wsdl.hd.Dvd"
> > class="com.sosnoski.ws.library.jibx2wsdl.hd.BluRayDvd"
> > name="bluRayDvd">
> > <structure map-as="tns:dvd1"/>
> > <value style="attribute" name="releaseYear"
> > get-method="getReleaseYear" set-method="setReleaseYear"/>
> > </mapping>
> > <mapping extends="com.sosnoski.ws.library.jibx2wsdl.hd.Dvd"
> > class="com.sosnoski.ws.library.jibx2wsdl.hd.Dvd$FutureDvd"
> > name="dvdFutureDvd">
> > <structure map-as="tns:dvd1"/>
> > <value style="element" name="format" get-method="getFormat"
> > set-method="setFormat" usage="optional"/>
> > </mapping>
> >
> > The substitution group structure is shown by the <mapping>s with
> names
> > which extend other <mapping>s. So in this case, the mappings for
> > <hdDvd>, <bluRayDvd>, and <hdDvd> all extend the mapping for the
> > com.sosnoski.ws.library.jibx2wsdl.hd.Dvd base class, and that base
> > class
> > <mapping> in turn extends the <mapping> for the IDvd interface,
> > which in
> > turn extends the <mapping> for the Item interface.
> >
> > That's how the substitution group handling works - you have a
> > <mapping>
> > for each element in the substitution group to some class, and that
> > <mapping> extends the class corresponding to the head of the
> > substitution group. If there are multiple layers in the
> > substitution you
> > just use multiple layers in the <mapping> extensions.
> >
> > But when you do this you can't just invoke the base class <mapping>
> > using a <structure map-as='base-class"/>, because that would create
> a
> > new child element. So it's often convenient to have abstract
> mappings
> > with a type-name but no element name in parallel to the mappings
> with
> > names used by the substitution group structure. In the sample
> > above, the
> > second mapping definition is of this type. The type-name for this
> > mapping is then referenced inside the other mappings to handle the
> XML
> > structure matching the base complexType.
> >
> > Hmmm. That still sounds confusing when I read over what I've
> written,
> > but hopefully it'll give you a start in the right direction. Feel
> free
> > to ask for clarification if needed.
> >
> > - Dennis
> >
> > Dennis M. Sosnoski
> > SOA 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
> >
> >
> >
> > amphoras wrote:
> > > Hi Joshua,
> > >
> > > Thank you so much for taking the time to help me with this. I
> have
> > > spent countless hours on this until my eyes glazed over. ;)
> > >
> > > The problem with my object model is that it's deeply
> > hierarchical and
> > > nested, and unfortunately I can't really change it. That's why
> > we are
> > > using JiBX. We figured that it's the only tool that can handle
> our
> > > crazy data structure. It works as advertised for us for
> everything
> > > but the schema group substitution.
> > >
> > > Since I simplified my example earlier, I did not tell you that
> > > actually SuperHeader has four more levels of superclasses above
> it,
> > > and it has two subclasses, one of which is Header. In addition,
> > > Container is contained by other objects as well. This is why I
> > ended
> > > up "double-declaring" these elements. So I tried to mimic your
> > > example as best as I could, following the way that you
> > double-declared
> > > the "Header" example. I also noticed that sometimes you used
> > "map-as"
> > > with the classname and other times with the mapping type-name. I
> > > think I read that they're supposed to be functionally
> > equivalent, but
> > > for some reason, I can only use the mapping type-name. Using the
> > > classname causes all kinds of errors.
> > >
> > > Sadly, there's still something wrong. The error that I get is:
> > >
> > > junit.framework.AssertionFailedError: Element
> > > "{http://www.gmail.com/my}Header<http://www.gmail.com/my%7DHeader>
> > <http://www.gmail.com/my%7DHeader>" has no mapping that extends
> > > org.standard.Header
> > > at junit.framework.Assert.fail(Assert.java:47)
> > >
> > > Normally, at this point I'll start to try different things. But
> > after
> > > having done that for hours before and not getting anywhere, I
> don't
> > > think that I have a good enough understanding of JiBX to succeed
> > that
> > > way. So I'm hoping that you or someone else can see what I'm
> doing
> > > wrong.
> > >
> > > Here's what I have:
> > >
> > > <binding>
> > > <namespace uri="http://www.gmail.com/st" default="elements"/>
> > > <namespace uri="http://www.gmail.com/my" default="none"
> > prefix="my"/>
> > >
> > > <mapping type-name="SuperHeader" abstract="true"
> > > class="org.standard.SuperHeader">
> > > <structure map-as="SuperSuperHeader"/>
> > > </mapping>
> > >
> > > <mapping name="SuperHeader"
> > > class="org.standard.SuperHeader"
> > > extends="org.standard.SuperSuperHeader">
> > > <structure map-as="SuperHeader"/>
> > > <value name="companyId" field="companyId" />
> > > </mapping>
> > >
> > >
> > > <mapping type-name="Header" abstract="true"
> > > class="org.standard.Header">
> > > <structure map-as="Header"/>
> > > </mapping>
> > >
> > > <mapping name="Header"
> > > class="org.standard.Header"
> > > extends="org.standard.SuperSuperHeader">
> > > <structure map-as="Header"/>
> > > <value name="branchId" field="branchId" />
> > > </mapping>
> > >
> > >
> > > <mapping name="myHeader"
> > > class="com.my.Header"
> > > extends="org.standard.Header">
> > > <structure map-as="Header"/>
> > > <value name="employeeId" field="employeeId"
> > ns="http://www.gmail.com/my" />
> > > </mapping>
> > >
> > >
> > > <mapping type-name="Container" abstract="true"
> > > class="org.standard.Container">
> > > <structure field="header"/>
> > > </mapping>
> > >
> > > <mapping name="Container"
> > > class="org.standard.Container">
> > > <structure map-as="Container" />
> > > </mapping>
> > > </binding>
> > >
> > > Again, I really appreciate your time and any help that you or
> > anybody
> > > else can give me.
> > >
> > > Thanks!
> > > --Polly
> > >
> >
> > ------------------------------------------------------------------------
> >
> >
> -------------------------------------------------------------------------
> > 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
> >
>
> -------------------------------------------------------------------------
> 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
>
--
--Polly
-------------------------------------------------------------------------
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