Hi Dirk,
There is two problems here: you seem to want to round-trip namespace
declaration and specify information about you xml like specifying the
schema location when marshalling.
1. Using namespaces
- If you want to let Castor to do the entire job you should use the
object model and the class descriptors generated by the Source
Generator. The descriptors save all the namespace information.
- If you don't want to use the Source Generator then you must a mapping
file. A new feature is available in the cvs to specify how to save
namespace. Here is a example:
First add a java Map in your object model to store the namespace prefix:
public MyClass {
Hashtable _namespaces;
....
public Hashtable getNamespaces() {
return _namespaces;
}
public void setNamespaces(Hashtable namespaces) {
_namespaces = namespaces;
}
....
}
Then update your mapping file to indicate that you want to save
namespaces:
<field name="namespaces" collection="hashtable" type="string">
<bind-xml node="namespace"/>
</field>
2 To specify the schema location you can use the method
Marshaller#setSchemaLocation. If each XML documents you are processing
used a different schemaLocation you'll have to save this information in
the object Model and tell Castor to ignore it while marshalling and set
it manually when creating a new Marshaller.
Hope that helps,
Arnaud
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 28, 2002 8:27 AM
> To: [EMAIL PROTECTED]
> Subject: [castor-dev] A total beginners Question, Namesspaces are
lost?
>
>
> Hi there,
> at first, Castor is a very nice tool.
> After reading manual and the stuff of the website I started a project.
>
> My question:
> When I read a special XML file with header part:
> <ZusyMeldung xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="
> http://www.zusy.de/2002/XMLSchema" xsi:schemaLocation="
> http://www.zusy.de/2002/XMLSchema ZusyAZ01.xsd">
> I unmarshall and the I marshall it. This part was gone.
> Why? And how can I avid this?
>
> Iater I will create thounds of XML-files and in my opinion is it not a
good
> way of creating a buffer for the file and
> replace by hand missing parts and write result out.
>
> cheers Dirk
>
> -----------------------------------------------------------
> 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