Thanks a lot, ��it works great with the 0.9.5.3. version!! :-)
But know I have another problem :-(
Let's suppose I have two JARS, each of them containing a mapping file:
[commons.jar]
|-> [common.xml]
<?xml version="1.0" encoding="UTF-8"?>
<mapping xmlns="">
<class name="NodeCommon" auto-complete="false">
<map-to xml="nodeCommon"/>
<field name="id" type="string" required="true" direct="true">
<bind-xml name="id" node="attribute"/>
</field>
</class>
</mapping>
[gui.jar]
|-> [gui.xml]
<?xml version="1.0" encoding="UTF-8"?>
<mapping>
<include href=""
<class name="NodeGui" extends="NodeCommon" auto-complete="false">
<map-to xml="node"/>
<field name="idGui" type="string" required="true" direct="true">
<bind-xml name="idGui" node="attribute"/>
</field>
</class>
</mapping>
I have both jars in my classpath. If know I execute:
// Load de mapping file
Mapping mappingGui = new Mapping();
URL url = "" "gui.xml");
System.err.println("url : " + url.toString()); // -> It shows: 'url : jar:file:/C:/tmp/castor/_gui.jar!/gui.xml'
mappingGui.loadMapping(url);
I get the following error in the line 'mappingGui.loadMapping(url)': ValidationException: unable to resolve reference: NodeCommon
I guess it is more a classloader problem that a castor one.
Thanks again for any help.
Isi,
-----Mensaje original-----
De: Keith Visco [mailto:[EMAIL PROTECTED]]
Enviado el: viernes, 23 de abril de 2004 2:19
Para: [EMAIL PROTECTED]
Asunto: Re: [castor-dev] Mapping XML, problems with include
Isidoro,
This should be working properly in Castor 0.9.5.3.
--Keith
> "Legido Mart�nez, Isidoro" wrote:
>
> Probably I'm doing something wrong, but I don't get the expected
> result when marshalling
> objects if I use the <include .../> into de mapping file.
> I will explain :-)
>
> ---------------------
> Initial situation
> ---------------------
> + Classes
> public class NodeCommon
> {
> public String id;
> }
>
> public class NodeGui extends NodeCommon
> {
> public String idGui;
> }
>
> + Mapping file
>
> [common.xml] -> Mapping for 'NodeCommon'
> <?xml version="1.0" encoding="UTF-8"?>
> <mapping xmlns="">
> <class name="NodeCommon" auto-complete="false">
> <map-to xml="nodeCommon"/>
> <field name="id" type="string" required="true" direct="true">
> <bind-xml name="id" node="attribute"/>
> </field>
> </class>
> </mapping>
>
> [gui.xml] -> Mapping for 'NodeGui' (which extends 'NodeCommon')
> <?xml version="1.0" encoding="UTF-8"?>
> <mapping>
> <include href="">
>
> <class name="NodeGui" extends="NodeCommon" auto-complete="false">
> <map-to xml="node"/>
> <field name="idGui" type="string" required="true" direct="true">
>
> <bind-xml name="idGui" node="attribute"/>
> </field>
> </class>
> </mapping>
>
> ---------------------
> Tests
> ---------------------
> If I execute the following program
>
> public class Main
> {
> public static void main(String[] args) throws Exception
> {
> NodeGui nodeGui = new NodeGui();
> nodeGui.id = "ID-CORE";
> nodeGui.idGui = "ID-GUI";
>
> // Load de mapping file
> Mapping mappingGui = new Mapping();
>
> mappingGui.loadMapping((new File("gui.xml")).toURL());
>
>
> // Get the XML representation
> StringWriter writer = new StringWriter();
> Marshaller marshaller = new Marshaller(writer);
>
> marshaller.setMapping(mappingGui);
> marshaller.marshal(nodeGui);
>
> System.err.println("XML : " +
> writer.getBuffer().toString());
> }
> }
>
> What I get is '<?xml version="1.0" encoding="UTF-8"?><node
> idGui="ID-GUI" xmlns=""/>' instead the expected
> '<?xml version="1.0" encoding="UTF-8"?><node idGui="ID-GUI"
> id="ID-CORE" xmlns=""/>'
>
> If I change gui.xml for the new version
>
> [gui.xml] -> Mapping for 'NodeGui'
> <?xml version="1.0" encoding="UTF-8"?>
> <mapping>
> <class name="NodeCommon" auto-complete="false">
> <map-to xml="nodeCommon"/>
> <field name="id" type="string" required="true" direct="true">
> <bind-xml name="id" node="attribute"/>
> </field>
> </class>
>
> <class name="NodeGui" extends="NodeCommon" auto-complete="false">
> <map-to xml="node"/>
> <field name="idGui" type="string" required="true" direct="true">
>
> <bind-xml name="idGui" node="attribute"/>
> </field>
> </class>
> </mapping>
>
> where I have changed the <include...> part for the common.xml's
> contents I get the expected result!!!!
>
> Any hint? Thanks in advanced for the help.
>
> Isi,
>
> PD: I am using the version '0.9.4.2'.
>
> ------------------------------------------------------
> ,-""""""-.
> /\j__/\ ( \`--.
> [EMAIL PROTECTED]@'/ _) >--.`.
> _{.:Y:_}_{{_,' ) )
> {_}`-^{_} ``` (_/
>
> Isidoro Legido Mart�nez
> Divisi�n de Sistemas de Informaci�n
>
> tecsidel
> Avda. Principe de Asturias 43-45, 2�
> 08012 Barcelona
> Tel: (+34) 93 292 21 10
> Fax: (+34) 93 292 28 28
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
