To be honest, that's a suprise to me as well. Something tells me that this is wrong .... I will be looking at this through the Jira issue you raised.

Werner

P.S. Joachim, do you have a view on this ?

Konni wrote:
I found what the problem was. First I thought, that I only need the classes
in the mapping file, which I want to modify. But after hours of tests, I
found out, that I have to put the whole corresponding class-structure there.
Otherwise all the statements in the mapping file will be ignored. I didn't
know that. The following mapping file works now:

<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
"http://castor.org/mapping.dtd";>

<mapping>
<description>Testbestellung</description>

<class name="bestellung.ORDERS05">
  <field name="IDOC" type="bestellung.IDOC">
    <bind-xml name="IDOC" node="element" />
  </field>
</class>

<class name="bestellung.IDOC">
  <field name="BEGIN" type="string">
    <bind-xml name="BLABLABLA" node="attribute" />
  </field>
  <field name="EDI_DC40" type="bestellung.EDI_DC40">
    <bind-xml name="EDI_DC40" node="element" />
  </field>
  <field name="E1EDK01" type="bestellung.E1EDK01">
    <bind-xml name="E1EDK01" node="element" />
  </field>
  <field name="E1EDKA1" type="bestellung.E1EDKA1">
    <bind-xml name="E1EDKA1" node="element" />
  </field>
  <field name="E1EDK02" type="bestellung.E1EDK02">
    <bind-xml name="E1EDK02" node="element" />
  </field>
  <field name="E1EDP01" type="bestellung.E1EDP01">
    <bind-xml name="E1EDP01" node="element" />
  </field>
</class>

<class name="bestellung.EDI_DC40" auto-complete="true" />
<class name="bestellung.E1EDK01" auto-complete="true" />
<class name="bestellung.E1EDKA1" auto-complete="true" />
<class name="bestellung.E1EDK02" auto-complete="true" />

<class name="bestellung.E1EDP01">
  <field name="POSEX" type="string" />
  <field name="MENGE" type="string" />
  <field name="MENEE" type="string" />
  <field name="E1EDP20" type="bestellung.E1EDP20">
    <bind-xml name="E1EDP20" node="element" />
  </field>
  <field name="E1EDP19" type="bestellung.E1EDP19">
    <bind-xml name="E1EDP19" node="element" />
  </field>
</class>

<class name="bestellung.E1EDP20" auto-complete="true" /> <class name="bestellung.E1EDP19" auto-complete="true" /> </mapping>


Best regards,
Konni



Konni wrote:
Now I reduced my application to only the first few XML tags. Now the
mapping file works, but now I get an additional attribute in the root tag
(ORDERS05) called "valid". How can I avoid this ? I still don't understand
why it works with only a few xml tags.

Here is the result:

<?xml version="1.0" encoding="iso-8859-1"?>
<ORDERS05 valid="true">
    <IDOC BLABLA="1"/>
</ORDERS05>

BR,
Konni

PS: The original code is also at jira.codehaus.org.



Werner Guttmann wrote:
Okay, that makes it more complete to understand what you are trying to achieve. With regards to your question, yes, this should be possible out of the box.

My working assumption is that your mapping file is not being picked up, for whatever reason. The fact that you are seeing one of the info messages does not necessarily indicate that Castor XML uses a descriptor as derived from the mapping.

Can you please create a Jira issue and somebody will be having a look ? When doing so, can you please follow the guidelines at

http://castor.org/how-to-submit-an-xml-bug.html

Regards
Werner

Konni wrote:
Yes, I used castor's code generator to generate the Java classes. Maybe
I was
misunderstanding something, since I'm new to castor. I'll explain what I
want to achieve.

We want to do EDI (especially purchase orders) with several suppliers.
Most
of them have SAP software. So I created a general XML schema definition
(XSD) for this message from which I generated the Java classes. But not
all
of the suppliers will follow correctly this guideline. So for them I
wanted
to use an individual mapping file.

Isn't this possible ?

Best regards,
Konni



Werner Guttmann wrote:
Hold on, did you use Castor's code generator to generate Java classes from your XML schema ? If yes, why do you want to use a mapping file at all ?

Werner

Konni wrote:
The fully qualified class name "bestellung.IDOC" is needed here.
Otherwise I
get a MappingException (Class not found...). Since the IDOC class
extends
the SAP_IDOC class, I also tried the following:

<class name="bestellung.SAP_IDOC">
or
<class name="bestellung.IDOC" extends="bestellung.SAP_IDOC">

Both have no effect. The getter and setter methods are in the SAP_IDOC
class.
I'm using castor version 1.1.2.1.

Here is a snippet of the corresponding XML schema. Maybe this helps.

<xs:complexType name="root">
  <xs:sequence>
   <xs:element name="IDOC" type ="SAP_IDOC"/>
</xs:sequence> </xs:complexType>

<xs:complexType name="SAP_IDOC">
  <xs:sequence>
   <xs:element name="EDI_DC40" type="header" minOccurs="0"/>
   <xs:element name="E1EDK01" type="K01"/>
   <xs:element name="E1EDKA1" type="KA1" maxOccurs="3"/>
   <xs:element name="E1EDK02" type="K02"/>
   <xs:element name="E1EDK35" type="K35" minOccurs="0"/>
   <xs:element name="E1EDP01" type="P01" maxOccurs="unbounded"/>
</xs:sequence> <xs:attribute name="BEGIN" type="xs:string" fixed="1"/>
</xs:complexType>

Best regards,
Konni




Werner Guttmann wrote:
Hi,

very hard to tell, as looking at this, I cannot spot the obvious
error. What about the fulyl qualified class name of the IDOC class ? If that#s wrong, Castor XML will use introspection, which might be what is happening ?

Regards
Werner

PS What Castor version are you using ?

Konni wrote:
I'm new to castor and I wanted to use a mapping file in order to
modify
my
xml-file in the marshalling process. But the mapping file has no
effect.

Here is the mapping file (Mapping.xml):

<?xml version="1.0" encoding="iso-8859-1"?>
<mapping>
<class name="bestellung.IDOC">
  <map-to xml="IDOC"/>
  <field name="BEGIN" type="string">
    <bind-xml name="BLABLABLA" node="attribute" />
  </field>
</class>
</mapping>

Here is the beginning of the original xml file:

<?xml version="1.0" encoding="iso-8859-1"?>
<ORDERS05>
    <IDOC BEGIN="1">
        <EDI_DC40 SEGMENT="1">
...

Here is my Java code:

... FileWriter writer = new
FileWriter("Testbestellung_neu.xml");
        Marshaller marshaller = new Marshaller(writer);
        Mapping mapping = new Mapping();
        mapping.loadMapping(new
URL("file:/D:/Temp/XML/Mapping.xml"));
        marshaller.setMapping(mapping);
        marshaller.setEncoding("iso-8859-1");
        marshaller.marshal(orders05);
        writer.close();
        ...

I expected the IDOC segment after the marshalling process like the
following:

<IDOC BLABLABLA="1">

The mapping file is in the classpath. When I call the program, there
is
the
INFO message "Loading mapping descriptors from ...". So the file
will
be
found. And there are no error messages.

What am I doing wrong ?

---------------------------------------------------------------------
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