Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

working some weird error reporting problem for DTD validation. augmented

* error.c valid.c: working some weird error reporting problem for
  DTD validation.
* runtest.c: augmented with DTD validation tests
* result/VC/OneID*: slight change in validation output.
Daniel
  • Loading branch information...
commit dbee0f19898734a172e40eb7d8a7169bbb5b3165 1 parent fc319af
Daniel Veillard authored
View
7 ChangeLog
@@ -1,3 +1,10 @@
+Mon Jun 27 14:41:14 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+ * error.c valid.c: working some weird error reporting problem for
+ DTD validation.
+ * runtest.c: augmented with DTD validation tests
+ * result/VC/OneID*: slight change in validation output.
+
Mon Jun 27 13:44:41 CEST 2005 Daniel Veillard <daniel@veillard.com>
* runtest.c: added most HTML tests
View
4 error.c
@@ -512,8 +512,10 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
} else if ((node != NULL) && (file == NULL)) {
int i;
- if ((node->doc != NULL) && (node->doc->URL != NULL))
+ if ((node->doc != NULL) && (node->doc->URL != NULL)) {
baseptr = node;
+ file = node->doc->URL;
+ }
for (i = 0;
((i < 10) && (node != NULL) && (node->type != XML_ELEMENT_NODE));
i++)
View
1  result/VC/OneID
@@ -1,7 +1,6 @@
./test/VC/OneID:4: validity error : Element doc has too may ID attributes defined : id
<!ATTLIST doc id ID #IMPLIED>
^
-./test/VC/OneID:0: validity error : Element doc has too many ID attributes defined : id
./test/VC/OneID:4: validity error : Element doc has 2 ID attribute defined in the internal subset : id
<!ATTLIST doc id ID #IMPLIED>
^
View
1  result/VC/OneID2
@@ -1,7 +1,6 @@
./test/VC/OneID2:3: validity error : Element doc has too may ID attributes defined : id
<!ATTLIST doc id ID #IMPLIED>
^
-validity error : Element doc has too many ID attributes defined : id
./test/VC/OneID2:3: validity error : Element doc has 2 ID attribute defined in the internal subset : id
<!ATTLIST doc id ID #IMPLIED>
^
View
1  result/VC/OneID3
@@ -1,7 +1,6 @@
test/VC/dtds/doc.dtd:2: validity error : Element doc has too may ID attributes defined : val
<!ATTLIST doc val ID #IMPLIED>
^
-./test/VC/OneID3:0: validity error : Element doc has too many ID attributes defined : val
test/VC/dtds/doc.dtd:2: validity error : Element doc has 2 ID attribute defined in the external subset : val
<!ATTLIST doc val ID #IMPLIED>
^
View
38 runtest.c
@@ -1537,7 +1537,7 @@ errParseTest(const char *filename, const char *result, const char *err,
int options) {
xmlDocPtr doc;
const char *base;
- int size, res;
+ int size, res = 0;
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML) {
@@ -1548,19 +1548,21 @@ errParseTest(const char *filename, const char *result, const char *err,
xmlGetWarningsDefaultValue = 1;
doc = xmlReadFile(filename, NULL, options);
}
- if (doc == NULL) {
- base = "";
- size = 0;
- } else {
+ xmlGetWarningsDefaultValue = 0;
+ if (result) {
+ if (doc == NULL) {
+ base = "";
+ size = 0;
+ } else {
#ifdef LIBXML_HTML_ENABLED
- if (options & XML_PARSE_HTML) {
- htmlDocDumpMemory(doc, (xmlChar **) &base, &size);
- } else
+ if (options & XML_PARSE_HTML) {
+ htmlDocDumpMemory(doc, (xmlChar **) &base, &size);
+ } else
#endif
- xmlDocDumpMemory(doc, (xmlChar **) &base, &size);
+ xmlDocDumpMemory(doc, (xmlChar **) &base, &size);
+ }
+ res = compareFileMem(result, base, size);
}
- xmlGetWarningsDefaultValue = 0;
- res = compareFileMem(result, base, size);
if (doc != NULL) {
if (base != NULL)
xmlFree((char *)base);
@@ -1576,6 +1578,9 @@ errParseTest(const char *filename, const char *result, const char *err,
fprintf(stderr, "Error for %s failed\n", filename);
return(-1);
}
+ } else if (options & XML_PARSE_DTDVALID) {
+ if (testErrorsSize != 0)
+ fprintf(stderr, "Validation for %s failed\n", filename);
}
return(0);
@@ -1872,6 +1877,17 @@ testDesc testDescriptions[] = {
saxParseTest, "./test/HTML/*", "result/HTML/", ".sax", NULL,
XML_PARSE_HTML },
#endif
+#ifdef LIBXML_VALID_ENABLED
+ { "Valid documents regression tests" ,
+ errParseTest, "./test/VCM/*", NULL, NULL, NULL,
+ XML_PARSE_DTDVALID },
+ { "Validity checking regression tests" ,
+ errParseTest, "./test/VC/*", "result/VC/", NULL, "",
+ XML_PARSE_DTDVALID },
+ { "General documents valid regression tests" ,
+ errParseTest, "./test/valid/*", "result/valid/", "", ".err",
+ XML_PARSE_DTDVALID },
+#endif
{NULL, NULL, NULL, NULL, NULL, NULL, 0}
};
View
11 valid.c
@@ -1868,6 +1868,7 @@ xmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem) {
* xmlScanIDAttributeDecl:
* @ctxt: the validation context
* @elem: the element name
+ * @err: whether to raise errors here
*
* Verify that the element don't have too many ID attributes
* declared.
@@ -1875,7 +1876,7 @@ xmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem) {
* Returns the number of ID attributes found.
*/
static int
-xmlScanIDAttributeDecl(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
+xmlScanIDAttributeDecl(xmlValidCtxtPtr ctxt, xmlElementPtr elem, int err) {
xmlAttributePtr cur;
int ret = 0;
@@ -1884,7 +1885,7 @@ xmlScanIDAttributeDecl(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
while (cur != NULL) {
if (cur->atype == XML_ATTRIBUTE_ID) {
ret ++;
- if (ret > 1)
+ if ((ret > 1) && (err))
xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_MULTIPLE_ID,
"Element %s has too many ID attributes defined : %s\n",
elem->name, cur->name, NULL);
@@ -2106,7 +2107,7 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
#ifdef LIBXML_VALID_ENABLED
if ((type == XML_ATTRIBUTE_ID) &&
- (xmlScanIDAttributeDecl(NULL, elemDef) != 0)) {
+ (xmlScanIDAttributeDecl(NULL, elemDef, 1) != 0)) {
xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_MULTIPLE_ID,
"Element %s has too may ID attributes defined : %s\n",
elem, name, NULL);
@@ -4042,7 +4043,7 @@ xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlElementPtr elem = xmlGetDtdElementDesc(doc->intSubset,
attr->elem);
if (elem != NULL) {
- nbId = xmlScanIDAttributeDecl(NULL, elem);
+ nbId = xmlScanIDAttributeDecl(NULL, elem, 0);
} else {
xmlAttributeTablePtr table;
@@ -4064,7 +4065,7 @@ xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
int extId = 0;
elem = xmlGetDtdElementDesc(doc->extSubset, attr->elem);
if (elem != NULL) {
- extId = xmlScanIDAttributeDecl(NULL, elem);
+ extId = xmlScanIDAttributeDecl(NULL, elem, 0);
}
if (extId > 1) {
xmlErrValidNodeNr(ctxt, (xmlNodePtr) attr, XML_DTD_ID_SUBSET,
Please sign in to comment.
Something went wrong with that request. Please try again.