Rich,

If you're getting namespaces in the output of non-Castor generated
source code, then they must be defined in the mapping file.

If you don't want them in the output, you can remove them from the
mapping file.

--Keith

Rich Trevor wrote:
> 
> Hello,
> 
> This might be a simple one but I don't see which switches or levers I need
> to pull...
> 
> I'm using a mapping file to unmarshal an xml file into a class. Then I just
> Marshal it back out to a different xml file.
> 
> I'm getting unwanted namespace identifiers (ns1) on the output file.
> 
> I've included a very simplified example that illustrates the behavior.
> 
> I'm using version 0.9.5.2.
> 
> Any help would be appreciated. Thanks,
> 
> R. Trevor
> 
> ///////////////
> // Simplified code example
> ///////////////
> 
>     String mapPath        = "test_mapping.xml";
>     String inputFileName  = "test_input.xml";
>     String outputFileName = "test_output.xml";
> 
>     // unmarshal the input file into the Test object
>     mapping.loadMapping(mapPath);
>     Unmarshaller unmar = new Unmarshaller(mapping);
>     Test test = (Test)unmar.unmarshal(new InputSource(new
> FileReader(inputFileName)));
> 
>     // marshal the Test object back out to the output file.
>     Marshaller mar = new Marshaller(new FileWriter(outputFileName));
>     mar.setMapping(mapping);
> 
>     // These method calls did not produce the desired effect (output =
> input)
>     //mar.setMarshalAsDocument(true);
>     //mar.setNSPrefixAtRoot(true);
>     //mar.setSchemaLocation("test.xsd");
>     //mar.setNamespaceMapping("", "http://www.foo.org/test";);
>     //mar.setNamespaceMapping(null, "http://www.foo.org/test";);
> 
>     mar.marshal(test);
> 
> ///////////////
> // test_input file
> ///////////////
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <test name="foo" >
> 
>     <abc>ABC</abc>
>     <xyz>XYZ</xyz>
> 
> </test>
> 
> ///////////////
> // test_output file
> ///////////////
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <test ns1:name="foo" xmlns:ns1="http://castor.exolab.org/";>
>     <ns1:abc>ABC</ns1:abc>
>     <ns1:xyz>XYZ</ns1:xyz>
> </test>
> 
> ///////////////
> // schema file (not referenced (?) by unmarshal or marshal, but defines
> desired default namespace)
> ///////////////
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="http://www.foo.org/test";
>         xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>         xmlns="http://www.foo.org/test";
>         elementFormDefault="qualified">
> 
>     <xsd:element name="test">
>         <xsd:complexType>
>             <xsd:sequence>
>                 <xsd:element name="abc" type="xsd:string"/>
>                 <xsd:element name="xyz" type="xsd:string"/>
>             </xsd:sequence>
>             <xsd:attribute name="name" type="xsd:string"/>
>         </xsd:complexType>
>     </xsd:element>
> </xsd:schema>
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to