Java Mailing List Archive

http://www.junlu.com/

Home » user.castor »

[castor-user] namespace issue

J p

2012-05-29

Replies: Find Java Web Hosting

Author LoginPost Reply


Marshaller marshaller = context.createMarshaller();
        marshaller.setMapping(mapping);   
        marshaller.setWriter(writer);
        marshaller.setNamespaceMapping("","http://www.books.com/120");
       marshaller.setSuppressNamespaces(true);

the xml generated by castor is not formatting properly if i give suppress namespace as true. Below is the xml which is being genererated, schemaLocation should have an xsi  prefix ex: xsi:shemaLocation.

Generated xml by castor;
<books xmlns="http://www.books.com/120"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://www.books.com/120 books.xsd">
    <book>
        <price>
            <value>1000</value>
        </price>
    </book>
</books>

the unwanted ns1 is generating if i give suppress namespace as false. but it generates xsi prefix for shemaLocation,

Marshaller marshaller = context.createMarshaller();
        marshaller.setMapping(mapping);   
        marshaller.setWriter(writer);
        marshaller.setNamespaceMapping("","http://www.books.com/120");
       marshaller.setSuppressNamespaces(false);

<books xmlns="http://www.books.com/120"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.books.com/120 books.xsd">
    <book>
        <price>
           <ns1:value xmlns:ns1="http://castor.exolab.org/">111111</ns1:value>
        </price>
    </book>
</books>

i dont want to have above ns1... in the xml. what should i do for that?

Thanks

©2008 junlu.com - Jax Systems, LLC, U.S.A.