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