Discussion:
DOMDocument::schemaValidate() -> libxml_get_errors()
Sébastien WENSKE
2007-04-05 13:30:12 UTC
Permalink
Hello all, (sorry for my bad english)

I've this script, it checks an XML file with an XSD file.
it reports errors in the XML with line number, but i've large XML file (up
to 560MB) and the line number
doesn't exceed 65535. for upper lines he return always 65535.

An idea ?

Thx in advance.

---HERE IS THE CODE---
<?
include("fonctions.php");

$xsd_file = $_COOKIE['xsd_file'];
$xml_file = "xml/".basename($_COOKIE['xml_file']);


libxml_use_internal_errors(true);

$xml = new DOMDocument();
$xml->load($xml_file);

if (!$xml->schemaValidate($xsd_file)) {
print '<b>DOMDocument::schemaValidate() Generated Errors!</b>';
libxml_display_errors();
}
?>
/// fonctions.php ///
<?

function libxml_display_error($error)

{

$return = "<br/>\n";

switch ($error->level) {

case LIBXML_ERR_WARNING:

$return .= "<b>Warning $error->code</b>: ";

break;

case LIBXML_ERR_ERROR:

$return .= "<b>Error $error->code</b>: ";

break;

case LIBXML_ERR_FATAL:

$return .= "<b>Fatal Error $error->code</b>: ";

break;

}

$return .= trim($error->message);

if ($error->file) {

$return .= " in <b>$error->file</b>";

}

$return .= " on line <b>$error->line</b>\n";



return $return;

}



function libxml_display_errors() {

$errors = libxml_get_errors();

foreach ($errors as $error) {

print libxml_display_error($error);

}

libxml_clear_errors();

}

?>
Tijnema !
2007-04-05 13:56:40 UTC
Permalink
Post by Sébastien WENSKE
Hello all, (sorry for my bad english)
I've this script, it checks an XML file with an XSD file.
it reports errors in the XML with line number, but i've large XML file (up
to 560MB) and the line number
doesn't exceed 65535. for upper lines he return always 65535.
An idea ?
Thx in advance.
I don't really understand what you're saying, but i might be able to
help you if you post the output of the script you posted, and then
tell what the expected output is.

Tijnema
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
JM Guillermin
2007-04-05 14:23:19 UTC
Permalink
If the error occure after the line 65535, libxml_get_errors() returns 65535.

Maybe this can help you Sébastien :

Class: LibXMLError
Properties (Read-Only):
(int) level
(int) code
(int) column
(string) message
(string) file
(int) line


jm

----- Original Message -----
From: "Tijnema !" <***@gmail.com>
To: "Sébastien WENSKE" <***@canardwc.com>
Cc: <php-***@lists.php.net>
Sent: Thursday, April 05, 2007 3:56 PM
Subject: Re: [PHP] DOMDocument::schemaValidate() -> libxml_get_errors()
Post by Sébastien WENSKE
Hello all, (sorry for my bad english)
I've this script, it checks an XML file with an XSD file.
it reports errors in the XML with line number, but i've large XML file (up
to 560MB) and the line number
doesn't exceed 65535. for upper lines he return always 65535.
An idea ?
Thx in advance.
I don't really understand what you're saying, but i might be able to
help you if you post the output of the script you posted, and then
tell what the expected output is.

Tijnema
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Sébastien WENSKE
2007-04-05 20:21:17 UTC
Permalink
Yes it's exactly the error, see the output :

DOMDocument::schemaValidate() Generated Errors!
Error 1871: Element 'EcheanceRMC': This element is not expected. in file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 33326 <- that's right
Error 1871: Element 'EcheanceRMC': This element is not expected. in file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's wrong the real line number is upper
[...]


is it du to the integer ?? (16bits ??)....




----- Original Message -----
From: "JM Guillermin" <***@jmgdev.net>
To: "Tijnema !" <***@gmail.com>; "Sébastien WENSKE" <***@canardwc.com>
Cc: <php-***@lists.php.net>
Sent: Thursday, April 05, 2007 4:23 PM
Subject: Re: [PHP] DOMDocument::schemaValidate() -> libxml_get_errors()
Post by JM Guillermin
If the error occure after the line 65535, libxml_get_errors() returns 65535.
Class: LibXMLError
(int) level
(int) code
(int) column
(string) message
(string) file
(int) line
jm
----- Original Message -----
Sent: Thursday, April 05, 2007 3:56 PM
Subject: Re: [PHP] DOMDocument::schemaValidate() -> libxml_get_errors()
Post by Sébastien WENSKE
Hello all, (sorry for my bad english)
I've this script, it checks an XML file with an XSD file.
it reports errors in the XML with line number, but i've large XML file (up
to 560MB) and the line number
doesn't exceed 65535. for upper lines he return always 65535.
An idea ?
Thx in advance.
I don't really understand what you're saying, but i might be able to
help you if you post the output of the script you posted, and then
tell what the expected output is.
Tijnema
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
JM Guillermin
2007-04-05 21:01:54 UTC
Permalink
It seems to be something like that, maybe try to find additional
informations on the LibXMLError class.

good luck.
jm

----- Original Message -----
From: "Sébastien WENSKE" <***@canardwc.com>
To: "JM Guillermin" <***@jmgdev.net>; "Tijnema !" <***@gmail.com>
Cc: <php-***@lists.php.net>
Sent: Thursday, April 05, 2007 10:21 PM
Subject: Re: [PHP] DOMDocument::schemaValidate() -> libxml_get_errors()


Yes it's exactly the error, see the output :

DOMDocument::schemaValidate() Generated Errors!
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 33326 <- that's
right
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's
wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's
wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's
wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's
wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's
wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's
wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's
wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line 65535 <- that's
wrong the real line number is upper
[...]


is it du to the integer ?? (16bits ??)....




----- Original Message -----
From: "JM Guillermin" <***@jmgdev.net>
To: "Tijnema !" <***@gmail.com>; "Sébastien WENSKE"
<***@canardwc.com>
Cc: <php-***@lists.php.net>
Sent: Thursday, April 05, 2007 4:23 PM
Subject: Re: [PHP] DOMDocument::schemaValidate() -> libxml_get_errors()
Post by JM Guillermin
If the error occure after the line 65535, libxml_get_errors() returns 65535.
Class: LibXMLError
(int) level
(int) code
(int) column
(string) message
(string) file
(int) line
jm
----- Original Message -----
Sent: Thursday, April 05, 2007 3:56 PM
Subject: Re: [PHP] DOMDocument::schemaValidate() -> libxml_get_errors()
Post by Sébastien WENSKE
Hello all, (sorry for my bad english)
I've this script, it checks an XML file with an XSD file.
it reports errors in the XML with line number, but i've large XML file (up
to 560MB) and the line number
doesn't exceed 65535. for upper lines he return always 65535.
An idea ?
Thx in advance.
I don't really understand what you're saying, but i might be able to
help you if you post the output of the script you posted, and then
tell what the expected output is.
Tijnema
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Tijnema !
2007-04-05 22:06:37 UTC
Permalink
Post by Sébastien WENSKE
DOMDocument::schemaValidate() Generated Errors!
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line
33326 <- that's right
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line
65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line
65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line
65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line
65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line
65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line
65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line
65535 <- that's wrong the real line number is upper
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line
65535 <- that's wrong the real line number is upper
[...]
is it du to the integer ?? (16bits ??)....
I don't think it has to do with integer, unless you're running in
16bit mode.. (PHP can't even run under 16bit i guess..). An integer
could a lot more. I think there are 2 options that make this error:
1) The libxml library itself doesn't support it.
2) The PHP bindings with the libxml don't support it.

In the first case you would need to contact the libxml authors, in the
second case, you might want to write a patch that fixes it :)

Tijnema
Post by Sébastien WENSKE
----- Original Message -----
Sent: Thursday, April 05, 2007 4:23 PM
Subject: Re: [PHP] DOMDocument::schemaValidate() -> libxml_get_errors()
Post by JM Guillermin
If the error occure after the line 65535, libxml_get_errors() returns
65535.
Post by JM Guillermin
Class: LibXMLError
(int) level
(int) code
(int) column
(string) message
(string) file
(int) line
jm
----- Original Message -----
Sent: Thursday, April 05, 2007 3:56 PM
Subject: Re: [PHP] DOMDocument::schemaValidate() -> libxml_get_errors()
Post by Sébastien WENSKE
Hello all, (sorry for my bad english)
I've this script, it checks an XML file with an XSD file.
it reports errors in the XML with line number, but i've large XML file
(up
Post by JM Guillermin
Post by Sébastien WENSKE
to 560MB) and the line number
doesn't exceed 65535. for upper lines he return always 65535.
An idea ?
Thx in advance.
I don't really understand what you're saying, but i might be able to
help you if you post the output of the script you posted, and then
tell what the expected output is.
Tijnema
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Rob Richards
2007-04-06 10:47:35 UTC
Permalink
Post by Tijnema !
Post by Sébastien WENSKE
DOMDocument::schemaValidate() Generated Errors!
Error 1871: Element 'EcheanceRMC': This element is not expected. in
file:///D%3A/wamp/www/XML%20Validator/xml/Edit4.xml on line
65535 <- that's wrong the real line number is upper
[...]
...
Post by Tijnema !
I don't think it has to do with integer, unless you're running in
16bit mode.. (PHP can't even run under 16bit i guess..). An integer
1) The libxml library itself doesn't support it.
2) The PHP bindings with the libxml don't support it.
In the first case you would need to contact the libxml authors, in the
second case, you might want to write a patch that fixes it :)
It is due to the structure in libxml2 (the line number in this case is
defined as unsigned short). This has been brought up before and wont be
changing as it would break API/AB compatibility. There really is little
you can do here.

Rob
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Continue reading on narkive:
Search results for 'DOMDocument::schemaValidate() -> libxml_get_errors()' (Questions and Answers)
3
replies
How to validate xml with php?
started 2008-06-03 13:02:07 UTC
programming & design
Loading...