Re: xml errors for validator (config file)

Le 5 févr. 2009 à 17:27, olivier Thereaux a écrit :
> On 5-Feb-09, at 2:08 AM, Karl Dubost wrote:
>> A first step and a few questions for a config file for xml parsing  
>> coming from libxml2
>
> Very nice! I can confirm that the identifier numbers are the same I  
> receive from the API.


# ISSUE 1

If you look at libxml2/doc/devhelp/libxml2-xmlerror.html (doc) or  
xmlerror.h (code)

You will notice that there are three cases with similar numbers  
identifier (see below).

* xmlErrorDomain      29 values
* xmlErrorLevel        4 values
* xmlParserErrors    731 values

The number identifier which is return is I guess only for the 3rd list?
Or is there a risk to have the same identifier for different types of  
errors?

enum xmlErrorDomain {
     XML_FROM_NONE = 0
     XML_FROM_PARSER = 1 /* The XML parser */
     XML_FROM_TREE = 2 /* The tree module */
     XML_FROM_NAMESPACE = 3 /* The XML Namespace module */
     XML_FROM_DTD = 4 /* The XML DTD validation with parser contex */
[…]
};

and

enum xmlErrorLevel {
     XML_ERR_NONE = 0
     XML_ERR_WARNING = 1 /* A simple warning */
     XML_ERR_ERROR = 2 /* A recoverable error */
     XML_ERR_FATAL = 3 /*  A fatal error */
};

and

enum xmlParserErrors {
     XML_ERR_OK = 0
     XML_ERR_INTERNAL_ERROR = 1 /* 1 */
     XML_ERR_NO_MEMORY = 2 /* 2 */
     XML_ERR_DOCUMENT_START = 3 /* 3 */
     XML_ERR_DOCUMENT_EMPTY = 4 /* 4 */
[…]
};


# ISSUE 2

In xmlerror.h, you will notice this line, which seems to put two  
different error type with the code.

     XML_SCHEMATRONV_ASSERT = 4000, /* 4000 */
     XML_SCHEMATRONV_REPORT,
     XML_MODULE_OPEN = 4900, /* 4900 */

I think it is a bug. In libxml2/doc/devhelp/libxml2-xmlerror.html, we  
can notice

     <a name="XML_SCHEMATRONV_ASSERT">XML_SCHEMATRONV_ASSERT</a> =  
4000 /* 4000 */
     <a name="XML_SCHEMATRONV_REPORT">XML_SCHEMATRONV_REPORT</a> = 4001
     <a name="XML_MODULE_OPEN">XML_MODULE_OPEN</a> = 4900 /* 4900 */


# ISSUE 3

only these are defined, if I'm not wrong, Maybe we just need these. :)

XML_ERR_INVALID_HEX_CHARREF "CharRef: invalid hexadecimal value\n";
XML_ERR_INVALID_DEC_CHARREF "CharRef: invalid decimal value\n";
XML_ERR_INVALID_CHARREF "CharRef: invalid value\n";
XML_ERR_INTERNAL_ERROR "internal error";
XML_ERR_PEREF_AT_EOF "PEReference at end of document\n";
XML_ERR_PEREF_IN_PROLOG "PEReference in prolog\n";
XML_ERR_PEREF_IN_EPILOG "PEReference in epilog\n";
XML_ERR_PEREF_NO_NAME "PEReference: no name\n";
XML_ERR_PEREF_SEMICOL_MISSING "PEReference: expecting ';'\n";
XML_ERR_ENTITY_LOOP "Detected an entity reference loop\n";
XML_ERR_ENTITY_NOT_STARTED "EntityValue: \" or ' expected\n";
XML_ERR_ENTITY_PE_INTERNAL "PEReferences forbidden in internal subset 
\n";
XML_ERR_ENTITY_NOT_FINISHED "EntityValue: \" or ' expected\n";
XML_ERR_ATTRIBUTE_NOT_STARTED "AttValue: \" or ' expected\n";
XML_ERR_LT_IN_ATTRIBUTE "Unescaped '<' not allowed in attributes values 
\n";
XML_ERR_LITERAL_NOT_STARTED "SystemLiteral \" or ' expected\n";
XML_ERR_LITERAL_NOT_FINISHED "Unfinished System or Public ID \" or '  
expected\n";
XML_ERR_MISPLACED_CDATA_END "Sequence ']]>' not allowed in content\n";
XML_ERR_URI_REQUIRED "SYSTEM or PUBLIC, the URI is missing\n";
XML_ERR_PUBID_REQUIRED "PUBLIC, the Public Identifier is missing\n";
XML_ERR_HYPHEN_IN_COMMENT "Comment must not contain '--' (double- 
hyphen)\n";
XML_ERR_PI_NOT_STARTED "xmlParsePI : no target name\n";
XML_ERR_RESERVED_XML_NAME "Invalid PI name\n";
XML_ERR_NOTATION_NOT_STARTED "NOTATION: Name expected here\n";
XML_ERR_NOTATION_NOT_FINISHED "'>' required to close NOTATION  
declaration\n";
XML_ERR_VALUE_REQUIRED "Entity value required\n";
XML_ERR_URI_FRAGMENT "Fragment not allowed";
XML_ERR_ATTLIST_NOT_STARTED "'(' required to start ATTLIST enumeration 
\n";
XML_ERR_NMTOKEN_REQUIRED "NmToken expected in ATTLIST enumeration\n";
XML_ERR_ATTLIST_NOT_FINISHED "')' required to finish ATTLIST  
enumeration\n";
XML_ERR_MIXED_NOT_STARTED "MixedContentDecl : '|' or ')*' expected\n";
XML_ERR_PCDATA_REQUIRED "MixedContentDecl : '#PCDATA' expected\n";
XML_ERR_ELEMCONTENT_NOT_STARTED "ContentDecl : Name or '(' expected\n";
XML_ERR_ELEMCONTENT_NOT_FINISHED "ContentDecl : ',' '|' or ')' expected 
\n";
XML_ERR_PEREF_IN_INT_SUBSET "PEReference: forbidden within markup decl  
in internal subset\n";
XML_ERR_GT_REQUIRED "expected '>'\n";
XML_ERR_CONDSEC_INVALID "XML conditional section '[' expected\n";
XML_ERR_EXT_SUBSET_NOT_FINISHED "Content error in the external subset 
\n";
XML_ERR_CONDSEC_INVALID_KEYWORD "conditional section INCLUDE or IGNORE  
keyword expected\n";
XML_ERR_CONDSEC_NOT_FINISHED "XML conditional section not closed\n";
XML_ERR_XMLDECL_NOT_STARTED "Text declaration '<?xml' required\n";
XML_ERR_XMLDECL_NOT_FINISHED "parsing XML declaration: '?>' expected\n";
XML_ERR_EXT_ENTITY_STANDALONE "external parsed entities cannot be  
standalone\n";
XML_ERR_ENTITYREF_SEMICOL_MISSING "EntityRef: expecting ';'\n";
XML_ERR_DOCTYPE_NOT_FINISHED "DOCTYPE improperly terminated\n";
XML_ERR_LTSLASH_REQUIRED "EndTag: '</' not found\n";
XML_ERR_EQUAL_REQUIRED "expected '='\n";
XML_ERR_STRING_NOT_CLOSED "String not closed expecting \" or '\n";
XML_ERR_STRING_NOT_STARTED "String not started expecting ' or \"\n";
XML_ERR_ENCODING_NAME "Invalid XML encoding name\n";
XML_ERR_STANDALONE_VALUE "standalone accepts only 'yes' or 'no'\n";
XML_ERR_DOCUMENT_EMPTY "Document is empty\n";
XML_ERR_DOCUMENT_END "Extra content at the end of the document\n";
XML_ERR_NOT_WELL_BALANCED "chunk is not well balanced\n";
XML_ERR_EXTRA_CONTENT "extra content at the end of well balanced chunk 
\n";
XML_ERR_VERSION_MISSING.drakkar27
"Malformed declaration expecting version\n";

Received on Saturday, 7 February 2009 05:04:56 UTC