HI Andrew,
Thanks for your suggestion. When I tried that with null and empty
("") prefix, it is producing output like below,
<?xml version="1.0" encoding="UTF-8"?>
<tmsettings xmlns=""
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nec.jp/method settings.xsd">
<ns1:logging xmlns:ns1="http://www.ne.jp/method/">
<ns1:logger ns1:name="tmcompiler" ns1:boundrylevel="10"/>
<ns1:logger ns1:name="tmwebapp" ns1:boundrylevel="10"/>
<ns1:logger ns1:name="tmclient" ns1:boundrylevel="10"/>
</ns1:logging>
</tmsettings>
Any help apprecited.
Thanks And Regards,
Jitesh
----- Original Message -----
*From:* Andrew Fawcett <mailto:[EMAIL PROTECTED]>
*To:* [email protected] <mailto:[email protected]>
*Sent:* Monday, August 22, 2005 9:16 PM
*Subject:* RE: [castor-user] xsi:schemaLocation Attribute
If you just want to avoid prefixing your elements, you should be
able to map your namespace to an empty string “” prefix without
having to disable namespaces.
------------------------------------------------------------------------
*From:* Kalyani Jitesh [mailto:[EMAIL PROTECTED]
*Sent:* 22 August 2005 13:15
*To:* [email protected] <mailto:[email protected]>
*Subject:* [castor-user] xsi:schemaLocation Attribute
Dear All,
I am having problem with **xsi:schemaLocation** Attribute during
marshalling. "xsi:" namespace in schemaLocation is also suppresed by
method marshaller.setSuppressNamespaces(true). This makes my XML
invalid.
I am using defaultnamespace (xmlns) attribute in root, because I do
not wish to tag my xml elements with prefix.
I am validating the xml against schema during Unmarshalling by
setting org.exolab.castor.parser.validation=true.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1. Initially my XML looks like below, (Before Unmarshalling)
_my XML:_
<?xml version="1.0" encoding="UTF-8"?>
<tmsettings xmlns="http://www.ne.jp/method"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
**xsi:schemaLocation**="http://www.ne.jp/method settings.xsd">
<logging> <logger name="tmcompiler" boundrylevel="10"/>
<logger name="tmclient" boundrylevel="10"/> </logging>
</tmsettings>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2. After marshalling, It look like below,
<?xml version="1.0" encoding="UTF-8"?>
<tmsettings xmlns="http://www.ne.jp/method"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
**schemaLocation**="http://www.ne.jp/method settings.xsd">
...
</tmsettings>
Here "xsi:" namespace is also surppresed by following code. Now this
XML I can not validate next time. So I need to produc same XML as
in 1.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I am using following code for Marshalling,
Marshaller marshaller = new Marshaller(new
OutputStreamWriter(System.out));
marshaller.setMapping(mapping);
marshaller.setSchemaLocation("http://www.nec.jp/method
settings.xsd");
marshaller.setNamespaceMapping(null,"http://www.nec.jp/mcone/tracemethod");
**marshaller.setSuppressNamespaces(true);***
*marshaller.marshal(tmsettings);
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I am using **marshaller.setSuppressNamespaces(true); **because if I
do'nt use it adds some default namespace prefix "ns1" to all
elements.
And xmlns=null.
Can anybody help me to get exact XML as in 1 after Marshlling?
Thanks in Advance.
Thanks And Regards,
Jitesh
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
**PS : my mapping.xml is as below,**
<?xml version="1.0"?>
<ca:mapping xmlns:ca="http://castor.exolab.org/"
xmlns="http://www.ne.jp/method/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://castor.exolab.org/ mapping.xsd">
<ca:class name="TMSettings">
<ca:map-to xml="tmsettings"/>
<ca:field name="loggerList" type="TMLoggerList">
<ca:bind-xml name="logging"/>
</ca:field>
</ca:class>
<ca:class name="TMLoggerList">
<ca:map-to xml="logging"/>
<ca:field name="loggerList" collection="map"
get-method="getLoggerList"
set-method="addLogger" type="TMLogger">
<ca:bind-xml name="logger"/>
</ca:field>
</ca:class>
<ca:class name="TMLogger">
<ca:map-to xml="logger"/>
<ca:field name="name" type="string">
<ca:bind-xml name="name" node="attribute"/>
</ca:field>
<ca:field name="boundryLevel" type="string">
<ca:bind-xml name="boundrylevel" node="attribute"/>
</ca:field>
</ca:class>
</ca:mapping>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CODA has a new world-class consolidation package.
Find out more about www.coda.com/ocra <http://www.coda.com/ocra>
------------------------------------------------------------------------
*
**The information in this message is confidential and may be legally
privileged. It may not be disclosed to, or used by, anyone other
than the addressee. If you receive this message in error, please
advise us immediately.
Internet emails are not necessarily secure. CODA does not accept
responsibility for changes to any email which occur after the email
has been sent. Attachments to this email may contain software
viruses, which could damage your systems. CODA has checked the
attachments for viruses before sending, but you should virus-check
them before opening.*