Title: Mapping XML, problems with include

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
 

Reply via email to