You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Hoebel, John" <Jo...@qwest.com> on 2004/02/11 16:47:50 UTC

Document is invalid: no grammar found.

I am trying to validate a xml document with a schema using an external
schema in Java:

    20           String schemaURI = "file:///test.xsd";
    21           DOMParser parser = new DOMParser();
    22
parser.setFeature("http://xml.org/sax/features/validation", true);
    23           parser.setProperty(
    24
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocat
ion",
    25              schemaURI);

I get:

[Error] :1:23: Document is invalid: no grammar found.
[Error] :1:23: Document root element "XXXX_INTERVAL_REQUEST", must match
DOCTYPE root "null"

I have tried different formats for the different schema uri value. None
make a difference.

I am using Xerces-J-bin.2.6.1 version.

Any suggestions? I would appreciate any help.

Thanks,
John


 

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


Re: Document is invalid: no grammar found.

Posted by Michael Glavassevich <mr...@apache.org>.
Hello John,

You need to turn on schema validation [1] as well otherwise the parser
will try to validate against a DTD.

Try adding this to your code:

parser.setFeature("http://apache.org/xml/features/validation/schema",
true);

Hope that helps.

[1] http://xml.apache.org/xerces2-j/features.html#validation.schema

On Wed, 11 Feb 2004, Hoebel, John wrote:

> I am trying to validate a xml document with a schema using an external
> schema in Java:
>
>     20           String schemaURI = "file:///test.xsd";
>     21           DOMParser parser = new DOMParser();
>     22
> parser.setFeature("http://xml.org/sax/features/validation", true);
>     23           parser.setProperty(
>     24
> "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocat
> ion",
>     25              schemaURI);
>
> I get:
>
> [Error] :1:23: Document is invalid: no grammar found.
> [Error] :1:23: Document root element "XXXX_INTERVAL_REQUEST", must match
> DOCTYPE root "null"
>
> I have tried different formats for the different schema uri value. None
> make a difference.
>
> I am using Xerces-J-bin.2.6.1 version.
>
> Any suggestions? I would appreciate any help.
>
> Thanks,
> John
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>

-- 
---------------------------
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

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


Re: Document is invalid: no grammar found.

Posted by Neil Delima <nd...@ca.ibm.com>.





Try setting the following features to true and see if it helps.

http://apache.org/xml/features/validation/schema
http://apache.org/xml/features/validation/schema-full-checking





                                                                                                                                       
                      "Hoebel, John"                                                                                                   
                      <John.Hoebel@qwes        To:       <xe...@xml.apache.org>                                                
                      t.com>                   cc:       "Hoebel, John" <Jo...@qwest.com>                                        
                                               Subject:  Document is invalid: no grammar found.                                        
                      02/11/2004 10:47                                                                                                 
                      AM                                                                                                               
                      Please respond to                                                                                                
                      xerces-j-user                                                                                                    
                                                                                                                                       



I am trying to validate a xml document with a schema using an external
schema in Java:

    20           String schemaURI = "file:///test.xsd";
    21           DOMParser parser = new DOMParser();
    22
parser.setFeature("http://xml.org/sax/features/validation", true);
    23           parser.setProperty(
    24
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocat
ion",
    25              schemaURI);

I get:

[Error] :1:23: Document is invalid: no grammar found.
[Error] :1:23: Document root element "XXXX_INTERVAL_REQUEST", must match
DOCTYPE root "null"

I have tried different formats for the different schema uri value. None
make a difference.

I am using Xerces-J-bin.2.6.1 version.

Any suggestions? I would appreciate any help.

Thanks,
John




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




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