HI ALL,

 

I am using castor mapping to load XML into Object. I am validating the XML file against schema by setting the

org.exolab.castor.parser.validation=true and other properties. Everything is working fine.

 

But I have probelm with the Schemalocation. I have given the schema location in XML file as below,

xsi:schemaLocation="http://www.ne.jp/method ./settings.xsd"

 

Xerces reads this schema location as relative path to XML files location. But Castor reads this location as relative path to current working directory.

With this bevaviour of Castor I am not able to validate the XML as actual working directory is not fixed.

 

How can I change this behaviour of Castor? Or can I set the ShemaLocation during UnMarshlling?

 

Please reply.

 

Thanks and Regards,

Jitesh

 
 
I have to introduce wrapper class TMLoggerList to have Map of TMLogger to avoid using location.
XML before and after unmarshalling and marshalling resp is same as below.
---------------------------------------------------------------------------------------------------------------------------
logger.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="5"/>
   <logger name="tmclient" boundrylevel="10"/>
   <logger name="tmwebapp" boundrylevel="15"/> 
  
</logging> 
</tmsettings>
---------------------------------------------------------------------------------------------------------------------------
mapping.xml
---------------------
<?xml version="1.0"?>
<ca:mapping  xmlns:ca="http://castor.exolab.org/"
    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" ns-uri="http://www.ne.jp/method" />
 <ca:field name="loggerList" type="TMLoggerList">
  <ca:bind-xml name="logging" />
 </ca:field>
 </ca:class>
 
<ca:class name="TMLoggerList">
<ca:map-to xml="logging" ns-uri="http://www.ne.jp/method" />
  <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" ns-uri="http://www.ne.jp/method" />
 <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>
---------------------------------------------------------------------------------------------------------------------------

Reply via email to