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