Since you've enabled parser validation, it looks like Xerces is trying
to validate your mapping file as well. You'll need to modify your
mapping file to point to either the mapping.dtd or mapping.xsd files for
proper validation.

Xerces is complaining because validation is enabled, but it doesn't know
where to find the DTD or Schema for the mapping file.

--Keith

"Yaldiz, Sunay" wrote:
> 
> Hello,
> 
> I am trying to use schema validation for the unmarshalled XML documents.
> I found in the mailing list
> I should set some properties in my castor.properties file as:
> 
> org.exolab.castor.parser.validation=true
> org.exolab.castor.parser.namespaces=true
> org.exolab.castor.features=http://xml.org/sax/features/validation,http:/
> /apache.org/xml/features/validation/schema,http://apache.org/xml/feature
> s/validation/dynamic
> 
> I did this part.The XML documents I want to marshall will not have a
> namespace, so
> I  wrote the following code, setting the nonamespaceschemalocation to a
> relative path where the
> Schema exists.
> 
> Mapping mapping = new Mapping();
> mapping.loadMapping(getMappingFile());
> Marshaller marshaller = new Marshaller(out);
> marshaller.setNoNamespaceSchemaLocation("Uthlande.xsd" );
> marshaller.setMapping(mapping);
> 
> Even before the marshaller is created, at the line
> mapping.loadMapping(...), I get an exception as follows:
> 
> org.xml.sax.SAXException: Parsing Error : Document is invalid: no
> grammar found.
> Line : 6
> Column : 9
> 
>         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
> Source)
>         at
> org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:555)
>         at
> org.exolab.castor.mapping.Mapping.loadMappingInternal(Mapping.java:515)
>         at
> org.exolab.castor.mapping.Mapping.loadMapping(Mapping.java:423)
>         at de.uthlande.io.xml.XMLWriter.save(XMLWriter.java:96)
>         at
> de.uthlande.io.xml.GlobalEnvironmentTest.testMarshall(GlobalEnvironmentT
> est.java:80)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:324)
>         at junit.framework.TestCase.runTest(TestCase.java:154)
>         at junit.framework.TestCase.runBare(TestCase.java:127)
>         at junit.framework.TestResult$1.protect(TestResult.java:106)
>         at junit.framework.TestResult.runProtected(TestResult.java:124)
>         at junit.framework.TestResult.run(TestResult.java:109)
>         at junit.framework.TestCase.run(TestCase.java:118)
>         at junit.framework.TestSuite.runTest(TestSuite.java:208)
>         at junit.framework.TestSuite.run(TestSuite.java:203)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> stRunner.java:392)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
> ner.java:276)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
> nner.java:167)
> 
> What should I do ? How can I use schema validation? Can you please
> provide a simple covering example?
> 
> Regards,
> Sunay
> 
> 
> 
> This e-mail contains confidential information for the exclusive attention of the 
> intended addressee. Any access of third parties to this e-mail is unauthorised. Any 
> use of this e-mail by unintended recipients such as copying, distribution, 
> disclosure etc. is prohibited and may be unlawful. When addressed to our clients the 
> content of this e-mail is subject to the General Terms and Conditions of GL's Group 
> of Companies applicable at the date of this e-mail.
> 
> GL's Group of Companies does not warrant and/or guarantee that this message at the 
> moment of receipt is authentic, correct and its communication free of errors, 
> interruption etc.
> 
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to