Hello,

I am new to Castor and I am really blocked on XSD validation. I have an
XML and an XSD to validate this XML.
I succeeded in writting a mapping file to converter my XML into my
business objects but now I would like to add
the validation of the XML. I looked at the example on the web site but I
am sorry, I don't understand.
Can you tell me why there is
xsi:schemaLocation="http://castor.exolab.org/ mapping.xsd"
in the mapping file ?

I have the following XML :
<jb_xs:REQUEST xmlns:jb_xs="http://www.jb.com/jb_xs";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.jb.com/jb_xs request.xsd">
        <jb_xs:RequestIdentificatio>
                <jb_xs:source>OrderManagement</jb_xs:source>
                <jb_xs:request_id>2</jb_xs:request_id>
...


And the following XSD :
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified" targetNamespace="http://www.jb.com/jb_xs";
xmlns:jb_xs="http://www.jb.com/jb_xs";>
        <xs:element name="REQUEST">
                <xs:complexType>
...

And the following castor.properties :
org.exolab.castor.parser.namespaces=true
org.exolab.castor.sax.features=http://xml.org/sax/features/validation,\
  http://apache.org/xml/features/validation/schema,\
  http://apache.org/xml/features/validation/schema-full-checking

So I tried with the following castorMapping.xml file according to your
example :
<mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xmlns="http://castor.exolab.org/";
         xmlns:jb_xs="http://www.jb.om/jb_xs";
         xsi:schemaLocation="http://castor.exolab.org/ mapping.xsd">
...

But when I run my Java code, I have the following error :
org.exolab.castor.mapping.MappingException: Nested error:
org.exolab.castor.xml.MarshalException: schema_reference.4: Failed to
read schema document 'mapping.xsd', because 1) could not find the
document; 2) the document could not be read; 3) the root element of the
document is not <xsd:schema>.{File:
file:///C:/Sonic/Workbench7.6/workspace/MPv3_EnrichTransform/castorMappi
ng.xml; line: 6; column: 69}

Can anyone help me please because I am really lost.

Thanks in advance.

Regards.

JB




Reply via email to