[castor-dev] namespace issue

J p <[email protected]> Tue, 29 May 2012 06:27:07 +0530
Newsgroups gmane.comp.java.castor.devel
Message-ID <CAGDpBkeM6hkx4E_vZLqiED+-M+OkuKLkKC79fskBrBoV5Bs_sw@mail.gmail.com>
--e89a8ff1c3d0543ce404c1225087
Content-Type: text/plain; charset=ISO-8859-1

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

--e89a8ff1c3d0543ce404c1225087
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><br>Marshaller marshaller =3D context.createMarshaller();<br>=A0=A0=A0 =
=A0=A0=A0 marshaller.setMapping(mapping);=A0=A0=A0 <br>=A0=A0=A0 =A0=A0=A0 =
marshaller.setWriter(writer);<br>=A0=A0=A0 =A0=A0=A0 marshaller.setNamespac=
eMapping(&quot;&quot;,&quot;<a href=3D"http://www.books.com/120">http://www=
.books.com/120</a>&quot;);<br>
=A0 =A0 =A0=A0<span style=3D"background-color:rgb(255,102,102)"> marshaller=
.setSuppressNamespaces(true);</span><br><br>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=A0 prefix=
 ex: xsi:shemaLocation.<br>
<br>Generated xml by castor;<br>&lt;books xmlns=3D&quot;<a href=3D"http://w=
ww.books.com/120">http://www.books.com/120</a>&quot;<br>=A0=A0=A0 xmlns:xsi=
=3D&quot;<a href=3D"http://www.w3.org/2001/XMLSchema-instance">http://www.w=
3.org/2001/XMLSchema-instance</a>&quot; <span style=3D"background-color:rgb=
(255,102,102)">schemaLocation=3D</span>&quot;<a href=3D"http://www.books.co=
m/120">http://www.books.com/120</a> books.xsd&quot;&gt;<br>
=A0=A0=A0 &lt;book&gt;<br>=A0=A0=A0=A0=A0=A0=A0 &lt;price&gt;<br>=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 &lt;value&gt;1000&lt;/value&gt;<br>=A0=A0=A0=A0=A0=
=A0=A0 &lt;/price&gt;<br>=A0=A0=A0 &lt;/book&gt;<br>&lt;/books&gt;<br><br>t=
he unwanted ns1 is generating if i give suppress namespace as false. but it=
 generates xsi prefix for shemaLocation,<br>
<br>Marshaller marshaller =3D context.createMarshaller();<br>=A0=A0=A0 =A0=
=A0=A0 marshaller.setMapping(mapping);=A0=A0=A0 <br>=A0=A0=A0 =A0=A0=A0 mar=
shaller.setWriter(writer);<br>=A0=A0=A0 =A0=A0=A0 marshaller.setNamespaceMa=
pping(&quot;&quot;,&quot;<a href=3D"http://www.books.com/120">http://www.bo=
oks.com/120</a>&quot;);<br>
=A0 =A0 =A0<span style=3D"background-color:rgb(255,153,102)">=A0<span style=
=3D"background-color:rgb(255,204,204)"> marshaller.setSuppressNamespaces(fa=
lse);</span></span><br><br>&lt;books xmlns=3D&quot;<a href=3D"http://www.bo=
oks.com/120">http://www.books.com/120</a>&quot;<br>
=A0=A0=A0 xmlns:xsi=3D&quot;<a href=3D"http://www.w3.org/2001/XMLSchema-ins=
tance">http://www.w3.org/2001/XMLSchema-instance</a>&quot;<span style=3D"ba=
ckground-color:rgb(255,204,204)"> xsi:schemaLocation=3D&quot;</span><a href=
=3D"http://www.books.com/120">http://www.books.com/120</a> books.xsd&quot;&=
gt;<br>
=A0=A0=A0 &lt;book&gt;<br>=A0=A0=A0=A0=A0=A0=A0 &lt;price&gt;<br>=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0<span style=3D"background-color:rgb(255,204,204)"> &lt=
;ns1:value xmlns:ns1=3D&quot;<a href=3D"http://castor.exolab.org/">http://c=
astor.exolab.org/</a>&quot;&gt;111111&lt;/ns1:value&gt;</span><br>
=A0=A0=A0=A0=A0=A0=A0 &lt;/price&gt;<br>=A0=A0=A0 &lt;/book&gt;<br>&lt;/boo=
ks&gt;<br><br>i dont want to have above ns1... in the xml. what should i do=
 for that?<br><br>Thanks<br><br>

--e89a8ff1c3d0543ce404c1225087--