You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Diego García González <di...@tid.es> on 2007/04/03 17:31:28 UTC

Validating XML against fixed XSD

Hi, I want to force the parser to always validate the xml instances 
against a unique XSD.
Here's part of my code:

        File schema = new File("./temp/schema.xsd");
       
        XmlOptions opt = new XmlOptions();
        opt.setDocumentType(XmlObject.Factory.parse(schema).schemaType());
        opt.setValidateOnSet();
       
        ConsultaDocument doc = 
ConsultaDocument.Factory.parse(XMLSource,opt);

But I get an exception on the last line: Exception in thread "main" 
java.lang.ClassCastException: 
org.apache.xmlbeans.impl.xb.xsdschema.impl.SchemaDocumentImpl

What's wrong with it?



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: Validating XML against fixed XSD

Posted by Diego García González <di...@tid.es>.
Sorry, I just noticed that was a silly question. Forget about it.

Thanks!

Diego García González escribió:
> Hi, I want to force the parser to always validate the xml instances 
> against a unique XSD.
> Here's part of my code:
>
>        File schema = new File("./temp/schema.xsd");
>              XmlOptions opt = new XmlOptions();
>        opt.setDocumentType(XmlObject.Factory.parse(schema).schemaType());
>        opt.setValidateOnSet();
>              ConsultaDocument doc = 
> ConsultaDocument.Factory.parse(XMLSource,opt);
>
> But I get an exception on the last line: Exception in thread "main" 
> java.lang.ClassCastException: 
> org.apache.xmlbeans.impl.xb.xsdschema.impl.SchemaDocumentImpl
>
> What's wrong with it?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org