I'm not sure why your root element name is coming out wrong, but you can
always change it using the Marshaller#setRootElement() method.
--Keith
Scott Curry wrote:
Hello,
I have done my best to search the user mailing list, the
documentation, and google to find an answer, but to no avail.
The marshaller is creating the wrong element name for the root element
of my document. Here is the schema (changed to protect the code) I
used to generate the castor objects and here is the code to do the
marshal.
----
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://namespace" xmlns="http://namespace"
version="0" xmlns:sv="http://namespace">
<xsd:element name="Example" type="sv:ExampleType"/>
<xsd:complexType name="ExampleType" mixed="true">
<xsd:attribute name="Attr1" type="xsd:string" use="required"/>
<xsd:attribute name="Attr2" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:schema>
----
Mapping mapping = new Mapping(getClass().getClassLoader());
// 1. Load the mapping information from the file
URL mappingFile =
CastorBaseDBO.class.getResource("castor-mapping.xml");
mapping.loadMapping(mappingFile);
Marshaller marshaller = new Marshaller(output);
marshaller.setResolver(resolver);
marshaller.setMapping(mapping);
marshaller.setSupressXMLDeclaration(suppressXMLDeclaration);
marshaller.setEncoding("UTF-8");
marshaller.marshal(value);
where the value variable is set to some castor object - the root
element (Example)
This did not work so I created a mapping file see below and that
worked sort of - I got the right name but lost all the rest of the XML
that should be generated.
<mapping>
<class name="package.ExampleType" auto-complete="true">
<map-to xml="Example" />
</class>
</mapping>
Is there an easy way to change the element name used for the marshal
that I have not tried? Why do I get back an empty element now that I
am using a mapping file.
TIA for the help!
Scott
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------