Well, I have attempted at a mapping file but obviously it is not working.
This exception ("Illegal Text data found as child of: langstring") is given
even when I use the static unmarshaller method w/o loading mappings.
It might help if I clarify what I want to acomplish instead of complicating
your thoughts with the mapping files.
I want to unmarshal an element that contains both attributes and text
content:
ex: <title lang="en">title</title>
What I want to know is if Castor can do that or not? All the examples that
I have looked at either had elements with attributes or elements that just
wraps text content but not BOTH so i am at lost to create a proper mapping
for this.
Thanks.
PS:
here is my attempt at the mapping file which i don't know if it is correct
or not. the mapping file only supply partial information, it is not a
complete list of all the classes.:
-------------------
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
1.0//EN" "http://Castor.exolab.org/mapping.dtd">
<mapping>
<description>Maps elements in imsmanifest.xml to Java object
Manifest</description>
<class name="com.ilrn.importer2.manifest.Manifest" auto-complete="true">
<map-to xml="manifest"/>
<field name="version" get-method="getVersion" set-method="setVersion"
type="string">
<bind-xml name="version" node="attribute"/>
</field>
</class>
<class name="com.ilrn.importer2.metadata.Title" auto-complete="true">
<field name="langstring" type="com.ilrn.importer2.metadata.Langstring"
collection="collection">
<bind-xml name="langstring" node="element" />
</field>
</class>
<class name="com.ilrn.importer2.metadata.Langstring" auto-complete="true">
<map-to xml="langstring" />
<field name="lang" type="string">
<bind-xml name="lang" node="attribute" />
</field>
<field name="content" type="string">
<bind-xml node="text" />
</field>
</class>
</mapping>
-------------------
-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 29, 2002 7:44 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Help with mapping element with attribute and
text content.
Ummm..what does your mapping file look like?
--Keith
Arthur Zhu wrote:
>
> Hi,
> I am new to Castor and have stumbled into what seems to be a "simple"
> problem.
>
> I want to unmarshalling some XML data that is like this:
> --------
> <title>
> <langstring xml:lang="en">Title in english</langstring>
> <langstring xml:lang="fr">Title in french</langstring>
> </title>
> ---------
>
> everytime i want use the unmarshaller, i get an
> "Illegal Text data found as child of: langstring"
> Exception.
>
> However if I wrapping the title TEXT data in another element, ie <content>
> then i don't get any exceptions:
>
> -----------
> <title>
> <langstring xml:lang="en"><content>Title in english</content></langstring>
> <langstring xml:lang="fr"><content>Title in french</content></langstring>
> </title>
> ----------
>
> --------
> I am not in liberty to change the XML spec so I have to find a way to get
> castor to unmarshal properly the above XML snippet or I will have to roll
my
> own data-binding code. :(
>
> Has anyone seen this problem or is this a limition of Castor unmarshalling
> framework?
>
> Or is there something that I can do with XML mapping to make this work?
>
> Thanks in advance.
>
> Arthur.
> ilrn.com
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev