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 aac <am...@inta.es> on 2007/05/10 13:03:25 UTC

No validation error message when the root element is erroneous

Hi all.
I am using the 2.9.0 Java version.

First at all, I am loading the complete grammar pool of the Schema files in
one parser object.

And then, when I am trying to validate an XML file, if the root element of
this XML file is incorrect (with a different namespace and/or with a
different name), I don't receive any error message in the Error handler.

Can you help me?
Thanks in advance.

Alberto
Remote Sensing Lab
INTA
Madrid (Spain)



-- 
View this message in context: http://www.nabble.com/No-validation-error-message-when-the-root-element-is-erroneous-tf3720894.html#a10410956
Sent from the Xerces - J - Users mailing list archive at Nabble.com.


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


Re: No validation error message when the root element is erroneous

Posted by aac <am...@inta.es>.

Ok. When I have disabled "dynamic validation" the error message event is
launched.
Thanks to Michael and Stanimir.

Regards.
Alberto


-- 
View this message in context: http://www.nabble.com/No-validation-error-message-when-the-root-element-is-erroneous-tf3720894.html#a10426564
Sent from the Xerces - J - Users mailing list archive at Nabble.com.


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


Re: No validation error message when the root element is erroneous

Posted by Stanimir Stamenkov <s7...@netscape.net>.
Thu, 10 May 2007 05:16:33 -0700 (PDT), /aac/:
> Thu, 10 May 2007 07:46:33 -0400, /Michael Glavassevich/:
> 
>> Did you mean that the element isn't 
>> declared anywhere? If that's the case, you should check if you have the 
>> dynamic validation [1] feature enabled (don't set it to true if that's not 
>> the behaviour you want).
>> 
>> [1] http://xerces.apache.org/xerces2-j/features.html#validation.dynamic
> 
> But, I have verified that,  if I change this root name by other string (not 
> defined in the schema) then it never reports an error.
[...]
> Besides I append the "features configuration" I define in my program before 
> the validation, as you can see the "dynamic" option is activated.
> 
> parserObject.setFeature("http://apache.org/xml/features/validation/dynamic", 
> true);

If I'm not missing something you need to disable the dynamic 
validation, instead.

-- 
Stanimir

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


Re: No validation error message when the root element is erroneous

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Alberto,

aac <am...@inta.es> wrote on 05/10/2007 08:16:33 AM:

> 
> Hi Michael
> Yes, you are right. 
> But what I mean is, for example: the root element of my XML file has the
> "MD_Metadata" name.
> I'm completely sure that in the Schema Grammar this element is included 
so
> it is possible to validate the rest of the XML file. And, in this case,
> everything is correct.
> 
> But, I have verified that,  if I change this root name by other string 
(not
> defined in the schema) then it never reports an error. Not even the 
first
> error message that I'm expecting, something like: "The root element is 
not
> defined in the schema files" or similar.
> Is it due to the Parser can't find the root element and then nothing is
> validated?

It's due to having the dynamic validation feature enabled. If you want an 
error to be reported you need to turn it off.

> Please tell me if now I have explained correctly my question.
> Besides I append the "features configuration" I define in my program 
before
> the validation, as you can see the "dynamic" option is activated.
> 
>    parserObject.setFeature("http://xml.org/sax/features/validation", 
true);
> 
> 
parserObject.setFeature("http://apache.org/xml/features/validation/dynamic",
> true);
> 
> 
parserObject.setFeature("http://apache.org/xml/features/validation/schema",
> true);
> 
> parserObject.setFeature("http://apache.
> org/xml/features/validation/schema-full-checking",
> true);
>     parserObject.setFeature("http://xml.org/sax/features/namespaces", 
true);
> 
> Thanks and regards
> Alberto
> -- 
> View this message in context: http://www.nabble.com/No-validation-
> 
error-message-when-the-root-element-is-erroneous-tf3720894.html#a10412233
> Sent from the Xerces - J - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.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: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: No validation error message when the root element is erroneous

Posted by aac <am...@inta.es>.
Hi Michael
Yes, you are right. 
But what I mean is, for example: the root element of my XML file has the
"MD_Metadata" name.
I'm completely sure that in the Schema Grammar this element is included so
it is possible to validate the rest of the XML file. And, in this case,
everything is correct.

But, I have verified that,  if I change this root name by other string (not
defined in the schema) then it never reports an error. Not even the first
error message that I'm expecting, something like: "The root element is not
defined in the schema files" or similar.
Is it due to the Parser can't find the root element and then nothing is
validated?

Please tell me if now I have explained correctly my question.
Besides I append the "features configuration" I define in my program before
the validation, as you can see the "dynamic" option is activated.

   parserObject.setFeature("http://xml.org/sax/features/validation", true);
   
parserObject.setFeature("http://apache.org/xml/features/validation/dynamic",
true);
   
parserObject.setFeature("http://apache.org/xml/features/validation/schema",
true);
   
parserObject.setFeature("http://apache.org/xml/features/validation/schema-full-checking",
true);
    parserObject.setFeature("http://xml.org/sax/features/namespaces", true);

Thanks and regards
Alberto
-- 
View this message in context: http://www.nabble.com/No-validation-error-message-when-the-root-element-is-erroneous-tf3720894.html#a10412233
Sent from the Xerces - J - Users mailing list archive at Nabble.com.


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


Re: No validation error message when the root element is erroneous

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Alberto,

Not sure what you mean by "the root element of this XML file is 
incorrect". Any element with a top-level declaration in your schema could 
potentially be used as a root element. Did you mean that the element isn't 
declared anywhere? If that's the case, you should check if you have the 
dynamic validation [1] feature enabled (don't set it to true if that's not 
the behaviour you want).

Thanks.

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

aac <am...@inta.es> wrote on 05/10/2007 07:03:25 AM:

> Hi all.
> I am using the 2.9.0 Java version.
> 
> First at all, I am loading the complete grammar pool of the Schema files 
in
> one parser object.
> 
> And then, when I am trying to validate an XML file, if the root element 
of
> this XML file is incorrect (with a different namespace and/or with a
> different name), I don't receive any error message in the Error handler.
> 
> Can you help me?
> Thanks in advance.
> 
> Alberto
> Remote Sensing Lab
> INTA
> Madrid (Spain)
> 
> 
> 
> -- 
> View this message in context: http://www.nabble.com/No-validation-
> 
error-message-when-the-root-element-is-erroneous-tf3720894.html#a10410956
> Sent from the Xerces - J - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.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: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org