No, the XPATH for your complexType named 'itemType' needs to be

/complexType:itemType

as (incompletely) documented at

http://www.castor.org/srcgen-binding.html

Regards
Werner

Drew Beechum wrote:
> So I've added to my binding file (which does have an effect since I
> can change from element to type object generation in the file)
> 
> <complexTypeBinding name="itemType">
>   <member name="availabilityStart" java-type="java.util.Date"
> handler="com.foo.domain.handler.AvailabilityStartHandler"/>
> </complexTypeBinding>
> 
> After running the ant script that generates the classes. Looking at
> the descriptor for ItemType, I still see the generic inner handler
> being assigned to availabilityStart. I assume I have a grammar issue
> with my specification, but I've been unable to find examples doing
> this. (The handler how-tos on the website give examples with mapping
> files.)
> 
> I've also tried doing an element binding on /playlist and playlist and
> item/playlist, but still see no changes in the descriptors.
> 
> Thanks
> 
> On 2/21/07, Werner Guttmann <[EMAIL PROTECTED]> wrote:
>> On the first problem, using a mapping file to set your custom field
>> handler is not the solution recommended. Can you please use a binding
>> file to instruct the XML code generator to use your custom field handler
>> and set it onto the according class(es).
>>
>> Werner
>>
>> > -----Original Message-----
>> > From: Drew Beechum [mailto:[EMAIL PROTECTED]
>> > Sent: Mittwoch, 21. Februar 2007 00:54
>> > To: [email protected]
>> > Subject: Re: [castor-user] Duplicate Attribute/Element and
>> > List size attribute
>> >
>> > I have been just using castor-1.1with no mapping file and
>> > using the default source generated classes.
>> > But that doesn't seem to be sufficient so here's what I'm facing now.
>> >
>> > Problem number 1 - Mapping dates from a non-standard format
>> >
>> > I have a basic type:
>> >
>> >        <xs:complexType name="itemType">
>> >                <xs:complexContent>
>> >                        <xs:extension base="baseDomain">
>> >                        <xs:sequence>
>> >                                <xs:element ref="availabilityStart"/>
>> >                                <xs:element ref="availabilityEnd"/>
>> >                        </xs:sequence>
>> >                <xs:attribute name="title" type="xs:string"/>
>> >                </xs:extension>
>> >                </xs:complexContent>
>> >        </xs:complexType>
>> >
>> >        <xs:element name="availabilityStart" type="xs:dateTime"/>
>> >        <xs:element name="availabilityEnd" type="xs:dateTime"/>
>> >
>> > This is extended  to a playlist object
>> >
>> >        <xs:element name="playlist">
>> > <xs:complexType>
>> >                <xs:complexContent>
>> >                        <xs:extension base="itemType">
>> >                                <xs:sequence>
>> >                                        <xs:element ref="items"/>
>> >                                        <xs:element
>> > ref="canSortPlaylist"/>
>> >                                        <xs:element
>> > ref="canSetLanguage"/>
>> >                                        <xs:element ref="canRepeat"/>
>> >                                </xs:sequence>
>> >                        </xs:extension>
>> >                </xs:complexContent>
>> >        </xs:complexType>
>> >        </xs:element>
>> >
>> > The availabilityStart and End dates come back as 01/01/2007 -
>> > 12:00:00 AM, which causes the unmarshalling to fail.
>> >
>> > I followed the example online for field handlers
>> > (http://www.castor.org/xml-fieldhandlers.html) and I can see
>> > it create the handlers, but never access the methods when I
>> > map using this file:
>> > (note AvailabilityStartHandler is a version of the first
>> > example, the ItemTypeDateHandler is the generic version)
>> >
>> > <?xml version="1.0"?>
>> > <mapping>
>> >
>> >  <class name="com.fool.domain.Playlist">
>> >     <field name="availabilityStart" type="string"
>> > handler="com.foo.domain.handler.AvailabilityStartHandler">
>> >        <bind-xml node="text"/>
>> >     </field>
>> >     <field name="availabilityEnd" type="string"
>> > handler="com.foo.domain.handler.ItemTypeDateHandler">
>> >        <bind-xml node="text"/>
>> >     </field>
>> >  </class>
>> >
>> >  <class name="com.foo.domain.ItemType">
>> >     <field name="availabilityStart" type="string"
>> > handler="com.disney.disl.domain.handler.ItemTypeDateHandler">
>> >        <bind-xml node="text"/>
>> >     </field>
>> >     <field name="availabilityEnd" type="string"
>> > handler="com.foo.domain.handler.ItemTypeDateHandler">
>> >        <bind-xml node="text"/>
>> >     </field>
>> >  </class>
>> >
>> > </mapping>
>> >
>> > I get errors still on the mapping since it doesn't like the
>> > date formats in the field by default. Is it possible to bind
>> > on the ItemType class and have the mapping picked up by
>> > children classes (e.g. Playlist) and others?
>> >
>> > 2nd problem - I don't know how to map this, but I have the
>> > complex type items that contains a series of arrays (videos,
>> > audios, playlists, games) and a set of attributes that are
>> > the array size. How do I map videos.size to the videos attribute?
>> >
>> > <xs:element name="items">
>> >                <xs:complexType>
>> >                        <xs:sequence>
>> >                                <xs:element name="video"
>> > type="videoType" minOccurs="0"
>> > maxOccurs="unbounded"/>
>> >                                <xs:element name="game" type="gameType"
>> > minOccurs="0"
>> > maxOccurs="unbounded"/>
>> >                                <xs:element name="audio"
>> > type="audioType" minOccurs="0"
>> > maxOccurs="unbounded"/>
>> >                                <xs:element name="playlist"
>> > type="playlistType" minOccurs="0"
>> > maxOccurs="unbounded"/>
>> >                        </xs:sequence>
>> >                        <xs:attribute name="games" type="xs:int"/>
>> >                        <xs:attribute name="audios" type="xs:int"/>
>> >                        <xs:attribute name="videos" type="xs:int"/>
>> >                        <xs:attribute name="playlists" type="xs:int"/>
>> >                </xs:complexType>
>> >        </xs:element>
>> >
>> >
>> > Thanks!
>> >
>> > On 2/16/07, Werner Guttmann <[EMAIL PROTECTED]> wrote:
>> > > Hi Drew,
>> > >
>> > > can you please provide us with a bit more information, such as what
>> > > the relevant XML schema (fragment) and the binding file looks like ?
>> > >
>> > > Regards
>> > > Werner
>> > >
>> > > Drew Beechum wrote:
>> > > > Hi,
>> > > >
>> > > > I've just been handed a project that needs to support
>> > pulling in and
>> > > > manipulating an xml response from a legacy service. I've got most
>> > > > everything bound in, but I'm running into a few problems
>> > and I don't
>> > > > know how to resolve them. For the record I'm using castor 1.1 and
>> > > > the ant sourcegen tools to build the classes.
>> > > >
>> > > > sample xml looks like this
>> > > >
>> > > > <playlist id=123>
>> > > >   <id>123</id>
>> > > >    <items videos=1 playlists=1>
>> > > >       <video id=124>
>> > > >          <id>124</id>
>> > > >       </video>
>> > > >       <playlist id=125>
>> > > >          <id>125</id>
>> > > >       </playlist>
>> > > >    </items>
>> > > > </playlist>
>> > > >
>> > > > Do source generation with the id attribute in place in the schema
>> > > > causes a conflict error. Big surprise, right? Is there
>> > anyway to resolve this?
>> > > > Preferably I'd like to map to the same member in the class, but
>> > > > every time I try to do "/[EMAIL PROTECTED]" it fails.
>> > > >
>> > > > Is there a clean way to populate the videos/playlists count
>> > > > attributes with the ArrayList<video>.size()?
>> > > >
>> > > > Thanks
>> > >
>> > >
>> > >
>> > ---------------------------------------------------------------------
>> > > To unsubscribe from this list please visit:
>> > >
>> > >     http://xircles.codehaus.org/manage_email
>> > >
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe from this list please visit:
>> >
>> >     http://xircles.codehaus.org/manage_email
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
> 
>    http://xircles.codehaus.org/manage_email
> 


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to