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

Reply via email to