| OLD | NEW |
| 1 /* | 1 /* |
| 2 * schematron.c : implementation of the Schematron schema validity checking | 2 * schematron.c : implementation of the Schematron schema validity checking |
| 3 * | 3 * |
| 4 * See Copyright for the status of this software. | 4 * See Copyright for the status of this software. |
| 5 * | 5 * |
| 6 * Daniel Veillard <daniel@veillard.com> | 6 * Daniel Veillard <daniel@veillard.com> |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 /* | 9 /* |
| 10 * TODO: | 10 * TODO: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 #define IS_SCHEMATRON(node, elem) \ | 47 #define IS_SCHEMATRON(node, elem) \ |
| 48 ((node != NULL) && (node->type == XML_ELEMENT_NODE ) && \ | 48 ((node != NULL) && (node->type == XML_ELEMENT_NODE ) && \ |
| 49 (node->ns != NULL) && \ | 49 (node->ns != NULL) && \ |
| 50 (xmlStrEqual(node->name, (const xmlChar *) elem)) && \ | 50 (xmlStrEqual(node->name, (const xmlChar *) elem)) && \ |
| 51 ((xmlStrEqual(node->ns->href, xmlSchematronNs)) || \ | 51 ((xmlStrEqual(node->ns->href, xmlSchematronNs)) || \ |
| 52 (xmlStrEqual(node->ns->href, xmlOldSchematronNs)))) | 52 (xmlStrEqual(node->ns->href, xmlOldSchematronNs)))) |
| 53 | 53 |
| 54 #define NEXT_SCHEMATRON(node) \ | 54 #define NEXT_SCHEMATRON(node) \ |
| 55 while (node != NULL) { \ | 55 while (node != NULL) { \ |
| 56 if ((node->type == XML_ELEMENT_NODE ) && (node->ns != NULL) && » \ | 56 if ((node->type == XML_ELEMENT_NODE ) && (node->ns != NULL) &&» \ |
| 57 ((xmlStrEqual(node->ns->href, xmlSchematronNs)) || \ | 57 ((xmlStrEqual(node->ns->href, xmlSchematronNs)) || \ |
| 58 (xmlStrEqual(node->ns->href, xmlOldSchematronNs)))) \ | 58 (xmlStrEqual(node->ns->href, xmlOldSchematronNs)))) \ |
| 59 break; \ | 59 break; \ |
| 60 node = node->next; \ | 60 node = node->next; \ |
| 61 } | 61 } |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * TODO: | 64 * TODO: |
| 65 * | 65 * |
| 66 * macro to flag unimplemented blocks | 66 * macro to flag unimplemented blocks |
| 67 */ | 67 */ |
| 68 #define TODO » » » » » » » » \ | 68 #define TODO» » » » » » » » \ |
| 69 xmlGenericError(xmlGenericErrorContext, \ | 69 xmlGenericError(xmlGenericErrorContext, \ |
| 70 "Unimplemented block at %s:%d\n", \ | 70 "Unimplemented block at %s:%d\n", \ |
| 71 __FILE__, __LINE__); | 71 __FILE__, __LINE__); |
| 72 | 72 |
| 73 typedef enum { | 73 typedef enum { |
| 74 XML_SCHEMATRON_ASSERT=1, | 74 XML_SCHEMATRON_ASSERT=1, |
| 75 XML_SCHEMATRON_REPORT=2 | 75 XML_SCHEMATRON_REPORT=2 |
| 76 } xmlSchematronTestType; | 76 } xmlSchematronTestType; |
| 77 | 77 |
| 78 /** | 78 /** |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 xmlDictPtr dict; | 159 xmlDictPtr dict; |
| 160 int nberrors; | 160 int nberrors; |
| 161 int err; | 161 int err; |
| 162 | 162 |
| 163 xmlSchematronPtr schema; | 163 xmlSchematronPtr schema; |
| 164 xmlXPathContextPtr xctxt; | 164 xmlXPathContextPtr xctxt; |
| 165 | 165 |
| 166 FILE *outputFile; /* if using XML_SCHEMATRON_OUT_FILE */ | 166 FILE *outputFile; /* if using XML_SCHEMATRON_OUT_FILE */ |
| 167 xmlBufferPtr outputBuffer; /* if using XML_SCHEMATRON_OUT_BUFFER */ | 167 xmlBufferPtr outputBuffer; /* if using XML_SCHEMATRON_OUT_BUFFER */ |
| 168 #ifdef LIBXML_OUTPUT_ENABLED |
| 168 xmlOutputWriteCallback iowrite; /* if using XML_SCHEMATRON_OUT_IO */ | 169 xmlOutputWriteCallback iowrite; /* if using XML_SCHEMATRON_OUT_IO */ |
| 169 xmlOutputCloseCallback ioclose; | 170 xmlOutputCloseCallback ioclose; |
| 171 #endif |
| 170 void *ioctx; | 172 void *ioctx; |
| 171 | 173 |
| 172 /* error reporting data */ | 174 /* error reporting data */ |
| 173 void *userData; /* user specific data block */ | 175 void *userData; /* user specific data block */ |
| 174 xmlSchematronValidityErrorFunc error;/* the callback in case of errors */ | 176 xmlSchematronValidityErrorFunc error;/* the callback in case of errors */ |
| 175 xmlSchematronValidityWarningFunc warning;/* callback in case of warning */ | 177 xmlSchematronValidityWarningFunc warning;/* callback in case of warning */ |
| 176 xmlStructuredErrorFunc serror; /* the structured function */ | 178 xmlStructuredErrorFunc serror; /* the structured function */ |
| 177 }; | 179 }; |
| 178 | 180 |
| 179 struct _xmlSchematronParserCtxt { | 181 struct _xmlSchematronParserCtxt { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 235 } |
| 234 | 236 |
| 235 /** | 237 /** |
| 236 * xmlSchematronPErr: | 238 * xmlSchematronPErr: |
| 237 * @ctxt: the parsing context | 239 * @ctxt: the parsing context |
| 238 * @node: the context node | 240 * @node: the context node |
| 239 * @error: the error code | 241 * @error: the error code |
| 240 * @msg: the error message | 242 * @msg: the error message |
| 241 * @str1: extra data | 243 * @str1: extra data |
| 242 * @str2: extra data | 244 * @str2: extra data |
| 243 * | 245 * |
| 244 * Handle a parser error | 246 * Handle a parser error |
| 245 */ | 247 */ |
| 246 static void | 248 static void |
| 247 xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error, | 249 xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error, |
| 248 const char *msg, const xmlChar * str1, const xmlChar * str2) | 250 const char *msg, const xmlChar * str1, const xmlChar * str2) |
| 249 { | 251 { |
| 250 xmlGenericErrorFunc channel = NULL; | 252 xmlGenericErrorFunc channel = NULL; |
| 251 xmlStructuredErrorFunc schannel = NULL; | 253 xmlStructuredErrorFunc schannel = NULL; |
| 252 void *data = NULL; | 254 void *data = NULL; |
| 253 | 255 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 xmlSchematronFree(xmlSchematronPtr schema) | 563 xmlSchematronFree(xmlSchematronPtr schema) |
| 562 { | 564 { |
| 563 if (schema == NULL) | 565 if (schema == NULL) |
| 564 return; | 566 return; |
| 565 | 567 |
| 566 if ((schema->doc != NULL) && (!(schema->preserve))) | 568 if ((schema->doc != NULL) && (!(schema->preserve))) |
| 567 xmlFreeDoc(schema->doc); | 569 xmlFreeDoc(schema->doc); |
| 568 | 570 |
| 569 if (schema->namespaces != NULL) | 571 if (schema->namespaces != NULL) |
| 570 xmlFree((char **) schema->namespaces); | 572 xmlFree((char **) schema->namespaces); |
| 571 | 573 |
| 572 xmlSchematronFreeRules(schema->rules); | 574 xmlSchematronFreeRules(schema->rules); |
| 573 xmlSchematronFreePatterns(schema->patterns); | 575 xmlSchematronFreePatterns(schema->patterns); |
| 574 xmlDictFree(schema->dict); | 576 xmlDictFree(schema->dict); |
| 575 xmlFree(schema); | 577 xmlFree(schema); |
| 576 } | 578 } |
| 577 | 579 |
| 578 /** | 580 /** |
| 579 * xmlSchematronNewParserCtxt: | 581 * xmlSchematronNewParserCtxt: |
| 580 * @URL: the location of the schema | 582 * @URL: the location of the schema |
| 581 * | 583 * |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 xmlRealloc((xmlChar **) ctxt->namespaces, ctxt->maxNamespaces * 4 * | 821 xmlRealloc((xmlChar **) ctxt->namespaces, ctxt->maxNamespaces * 4 * |
| 820 sizeof(const xmlChar *)); | 822 sizeof(const xmlChar *)); |
| 821 if (tmp == NULL) { | 823 if (tmp == NULL) { |
| 822 xmlSchematronPErrMemory(NULL, "allocating parser namespaces", | 824 xmlSchematronPErrMemory(NULL, "allocating parser namespaces", |
| 823 NULL); | 825 NULL); |
| 824 return; | 826 return; |
| 825 } | 827 } |
| 826 ctxt->namespaces = tmp; | 828 ctxt->namespaces = tmp; |
| 827 ctxt->maxNamespaces *= 2; | 829 ctxt->maxNamespaces *= 2; |
| 828 } | 830 } |
| 829 ctxt->namespaces[2 * ctxt->nbNamespaces] = | 831 ctxt->namespaces[2 * ctxt->nbNamespaces] = |
| 830 xmlDictLookup(ctxt->dict, ns, -1); | 832 xmlDictLookup(ctxt->dict, ns, -1); |
| 831 ctxt->namespaces[2 * ctxt->nbNamespaces + 1] = | 833 ctxt->namespaces[2 * ctxt->nbNamespaces + 1] = |
| 832 xmlDictLookup(ctxt->dict, prefix, -1); | 834 xmlDictLookup(ctxt->dict, prefix, -1); |
| 833 ctxt->nbNamespaces++; | 835 ctxt->nbNamespaces++; |
| 834 ctxt->namespaces[2 * ctxt->nbNamespaces] = NULL; | 836 ctxt->namespaces[2 * ctxt->nbNamespaces] = NULL; |
| 835 ctxt->namespaces[2 * ctxt->nbNamespaces + 1] = NULL; | 837 ctxt->namespaces[2 * ctxt->nbNamespaces + 1] = NULL; |
| 836 | 838 |
| 837 } | 839 } |
| 838 | 840 |
| 839 /** | 841 /** |
| 840 * xmlSchematronParseRule: | 842 * xmlSchematronParseRule: |
| 841 * @ctxt: a schema validation context | 843 * @ctxt: a schema validation context |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 * @ctxt: the validation context | 1283 * @ctxt: the validation context |
| 1282 * @test: the test node | 1284 * @test: the test node |
| 1283 * @cur: the current node tested | 1285 * @cur: the current node tested |
| 1284 * | 1286 * |
| 1285 * Build the string being reported to the user. | 1287 * Build the string being reported to the user. |
| 1286 * | 1288 * |
| 1287 * Returns a report string or NULL in case of error. The string needs | 1289 * Returns a report string or NULL in case of error. The string needs |
| 1288 * to be deallocated by teh caller | 1290 * to be deallocated by teh caller |
| 1289 */ | 1291 */ |
| 1290 static xmlChar * | 1292 static xmlChar * |
| 1291 xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt, | 1293 xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt, |
| 1292 xmlNodePtr test, xmlNodePtr cur) { | 1294 xmlNodePtr test, xmlNodePtr cur) { |
| 1293 xmlChar *ret = NULL; | 1295 xmlChar *ret = NULL; |
| 1294 xmlNodePtr child, node; | 1296 xmlNodePtr child, node; |
| 1295 | 1297 |
| 1296 if ((test == NULL) || (cur == NULL)) | 1298 if ((test == NULL) || (cur == NULL)) |
| 1297 return(ret); | 1299 return(ret); |
| 1298 | 1300 |
| 1299 child = test->children; | 1301 child = test->children; |
| 1300 while (child != NULL) { | 1302 while (child != NULL) { |
| 1301 if ((child->type == XML_TEXT_NODE) || | 1303 if ((child->type == XML_TEXT_NODE) || |
| 1302 (child->type == XML_CDATA_SECTION_NODE)) | 1304 (child->type == XML_CDATA_SECTION_NODE)) |
| 1303 ret = xmlStrcat(ret, child->content); | 1305 ret = xmlStrcat(ret, child->content); |
| 1304 else if (IS_SCHEMATRON(child, "name")) { | 1306 else if (IS_SCHEMATRON(child, "name")) { |
| 1305 xmlChar *path; | 1307 xmlChar *path; |
| 1306 | 1308 |
| 1307 path = xmlGetNoNsProp(child, BAD_CAST "path"); | 1309 path = xmlGetNoNsProp(child, BAD_CAST "path"); |
| 1308 | 1310 |
| 1309 node = cur; | 1311 node = cur; |
| 1310 if (path != NULL) { | 1312 if (path != NULL) { |
| 1311 node = xmlSchematronGetNode(ctxt, cur, path); | 1313 node = xmlSchematronGetNode(ctxt, cur, path); |
| 1312 if (node == NULL) | 1314 if (node == NULL) |
| 1313 node = cur; | 1315 node = cur; |
| 1314 xmlFree(path); | 1316 xmlFree(path); |
| 1315 } | 1317 } |
| 1316 | 1318 |
| 1317 » if ((node->ns == NULL) || (node->ns->prefix == NULL)) | 1319 » if ((node->ns == NULL) || (node->ns->prefix == NULL)) |
| 1318 ret = xmlStrcat(ret, node->name); | 1320 ret = xmlStrcat(ret, node->name); |
| 1319 else { | 1321 else { |
| 1320 ret = xmlStrcat(ret, node->ns->prefix); | 1322 ret = xmlStrcat(ret, node->ns->prefix); |
| 1321 ret = xmlStrcat(ret, BAD_CAST ":"); | 1323 ret = xmlStrcat(ret, BAD_CAST ":"); |
| 1322 ret = xmlStrcat(ret, node->name); | 1324 ret = xmlStrcat(ret, node->name); |
| 1323 } | 1325 } |
| 1324 } else { | 1326 } else { |
| 1325 child = child->next; | 1327 child = child->next; |
| 1326 continue; | 1328 continue; |
| 1327 } | 1329 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1358 * xmlSchematronReportSuccess: | 1360 * xmlSchematronReportSuccess: |
| 1359 * @ctxt: the validation context | 1361 * @ctxt: the validation context |
| 1360 * @test: the compiled test | 1362 * @test: the compiled test |
| 1361 * @cur: the current node tested | 1363 * @cur: the current node tested |
| 1362 * @success: boolean value for the result | 1364 * @success: boolean value for the result |
| 1363 * | 1365 * |
| 1364 * called from the validation engine when an assert or report test have | 1366 * called from the validation engine when an assert or report test have |
| 1365 * been done. | 1367 * been done. |
| 1366 */ | 1368 */ |
| 1367 static void | 1369 static void |
| 1368 xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt, | 1370 xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt, |
| 1369 xmlSchematronTestPtr test, xmlNodePtr cur, xmlSchematronPatte
rnPtr pattern, int success) { | 1371 xmlSchematronTestPtr test, xmlNodePtr cur, xmlSchematronPatte
rnPtr pattern, int success) { |
| 1370 if ((ctxt == NULL) || (cur == NULL) || (test == NULL)) | 1372 if ((ctxt == NULL) || (cur == NULL) || (test == NULL)) |
| 1371 return; | 1373 return; |
| 1372 /* if quiet and not SVRL report only failures */ | 1374 /* if quiet and not SVRL report only failures */ |
| 1373 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) && | 1375 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) && |
| 1374 ((ctxt->flags & XML_SCHEMATRON_OUT_XML) == 0) && | 1376 ((ctxt->flags & XML_SCHEMATRON_OUT_XML) == 0) && |
| 1375 (test->type == XML_SCHEMATRON_REPORT)) | 1377 (test->type == XML_SCHEMATRON_REPORT)) |
| 1376 return; | 1378 return; |
| 1377 if (ctxt->flags & XML_SCHEMATRON_OUT_XML) { | 1379 if (ctxt->flags & XML_SCHEMATRON_OUT_XML) { |
| 1378 TODO | 1380 TODO |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 } | 1440 } |
| 1439 | 1441 |
| 1440 /** | 1442 /** |
| 1441 * xmlSchematronReportPattern: | 1443 * xmlSchematronReportPattern: |
| 1442 * @ctxt: the validation context | 1444 * @ctxt: the validation context |
| 1443 * @pattern: the current pattern | 1445 * @pattern: the current pattern |
| 1444 * | 1446 * |
| 1445 * called from the validation engine when starting to check a pattern | 1447 * called from the validation engine when starting to check a pattern |
| 1446 */ | 1448 */ |
| 1447 static void | 1449 static void |
| 1448 xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt, | 1450 xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt, |
| 1449 xmlSchematronPatternPtr pattern) { | 1451 xmlSchematronPatternPtr pattern) { |
| 1450 if ((ctxt == NULL) || (pattern == NULL)) | 1452 if ((ctxt == NULL) || (pattern == NULL)) |
| 1451 return; | 1453 return; |
| 1452 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) || (ctxt->flags & XML_SCHEMATRO
N_OUT_ERROR)) /* Error gives pattern name as part of error */ | 1454 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) || (ctxt->flags & XML_SCHEMATRO
N_OUT_ERROR)) /* Error gives pattern name as part of error */ |
| 1453 return; | 1455 return; |
| 1454 if (ctxt->flags & XML_SCHEMATRON_OUT_XML) { | 1456 if (ctxt->flags & XML_SCHEMATRON_OUT_XML) { |
| 1455 TODO | 1457 TODO |
| 1456 } else { | 1458 } else { |
| 1457 char msg[1000]; | 1459 char msg[1000]; |
| 1458 | 1460 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 return(cur); | 1567 return(cur); |
| 1566 } | 1568 } |
| 1567 } | 1569 } |
| 1568 | 1570 |
| 1569 while (cur->next != NULL) { | 1571 while (cur->next != NULL) { |
| 1570 cur = cur->next; | 1572 cur = cur->next; |
| 1571 if ((cur->type != XML_ENTITY_DECL) && | 1573 if ((cur->type != XML_ENTITY_DECL) && |
| 1572 (cur->type != XML_DTD_NODE)) | 1574 (cur->type != XML_DTD_NODE)) |
| 1573 return(cur); | 1575 return(cur); |
| 1574 } | 1576 } |
| 1575 | 1577 |
| 1576 do { | 1578 do { |
| 1577 cur = cur->parent; | 1579 cur = cur->parent; |
| 1578 if (cur == NULL) break; | 1580 if (cur == NULL) break; |
| 1579 if (cur->type == XML_DOCUMENT_NODE) return(NULL); | 1581 if (cur->type == XML_DOCUMENT_NODE) return(NULL); |
| 1580 if (cur->next != NULL) { | 1582 if (cur->next != NULL) { |
| 1581 cur = cur->next; | 1583 cur = cur->next; |
| 1582 return(cur); | 1584 return(cur); |
| 1583 } | 1585 } |
| 1584 } while (cur != NULL); | 1586 } while (cur != NULL); |
| 1585 return(cur); | 1587 return(cur); |
| 1586 } | 1588 } |
| 1587 | 1589 |
| 1588 /** | 1590 /** |
| 1589 * xmlSchematronRunTest: | 1591 * xmlSchematronRunTest: |
| 1590 * @ctxt: the schema validation context | 1592 * @ctxt: the schema validation context |
| 1591 * @test: the current test | 1593 * @test: the current test |
| 1592 * @instance: the document instace tree | 1594 * @instance: the document instace tree |
| 1593 * @cur: the current node in the instance | 1595 * @cur: the current node in the instance |
| 1594 * | 1596 * |
| 1595 * Validate a rule against a tree instance at a given position | 1597 * Validate a rule against a tree instance at a given position |
| 1596 * | 1598 * |
| 1597 * Returns 1 in case of success, 0 if error and -1 in case of internal error | 1599 * Returns 1 in case of success, 0 if error and -1 in case of internal error |
| 1598 */ | 1600 */ |
| 1599 static int | 1601 static int |
| 1600 xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt, | 1602 xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt, |
| 1601 xmlSchematronTestPtr test, xmlDocPtr instance, xmlNodePtr cur, xmlSchematro
nPatternPtr pattern) | 1603 xmlSchematronTestPtr test, xmlDocPtr instance, xmlNodePtr cur, xmlSchematro
nPatternPtr pattern) |
| 1602 { | 1604 { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 ctxt->nberrors++; | 1648 ctxt->nberrors++; |
| 1647 | 1649 |
| 1648 xmlSchematronReportSuccess(ctxt, test, cur, pattern, !failed); | 1650 xmlSchematronReportSuccess(ctxt, test, cur, pattern, !failed); |
| 1649 | 1651 |
| 1650 return(!failed); | 1652 return(!failed); |
| 1651 } | 1653 } |
| 1652 | 1654 |
| 1653 /** | 1655 /** |
| 1654 * xmlSchematronValidateDoc: | 1656 * xmlSchematronValidateDoc: |
| 1655 * @ctxt: the schema validation context | 1657 * @ctxt: the schema validation context |
| 1656 * @instance: the document instace tree | 1658 * @instance: the document instace tree |
| 1657 * | 1659 * |
| 1658 * Validate a tree instance against the schematron | 1660 * Validate a tree instance against the schematron |
| 1659 * | 1661 * |
| 1660 * Returns 0 in case of success, -1 in case of internal error | 1662 * Returns 0 in case of success, -1 in case of internal error |
| 1661 * and an error count otherwise. | 1663 * and an error count otherwise. |
| 1662 */ | 1664 */ |
| 1663 int | 1665 int |
| 1664 xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance) | 1666 xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance) |
| 1665 { | 1667 { |
| 1666 xmlNodePtr cur, root; | 1668 xmlNodePtr cur, root; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1690 while (rule != NULL) { | 1692 while (rule != NULL) { |
| 1691 if (xmlPatternMatch(rule->pattern, cur) == 1) { | 1693 if (xmlPatternMatch(rule->pattern, cur) == 1) { |
| 1692 test = rule->tests; | 1694 test = rule->tests; |
| 1693 while (test != NULL) { | 1695 while (test != NULL) { |
| 1694 xmlSchematronRunTest(ctxt, test, instance, cur, (xmlSche
matronPatternPtr)rule->pattern); | 1696 xmlSchematronRunTest(ctxt, test, instance, cur, (xmlSche
matronPatternPtr)rule->pattern); |
| 1695 test = test->next; | 1697 test = test->next; |
| 1696 } | 1698 } |
| 1697 } | 1699 } |
| 1698 rule = rule->next; | 1700 rule = rule->next; |
| 1699 } | 1701 } |
| 1700 » | 1702 |
| 1701 cur = xmlSchematronNextNode(cur); | 1703 cur = xmlSchematronNextNode(cur); |
| 1702 } | 1704 } |
| 1703 } else { | 1705 } else { |
| 1704 /* | 1706 /* |
| 1705 * Process all contexts one at a time | 1707 * Process all contexts one at a time |
| 1706 */ | 1708 */ |
| 1707 pattern = ctxt->schema->patterns; | 1709 pattern = ctxt->schema->patterns; |
| 1708 » | 1710 |
| 1709 while (pattern != NULL) { | 1711 while (pattern != NULL) { |
| 1710 xmlSchematronReportPattern(ctxt, pattern); | 1712 xmlSchematronReportPattern(ctxt, pattern); |
| 1711 | 1713 |
| 1712 /* | 1714 /* |
| 1713 * TODO convert the pattern rule to a direct XPath and | 1715 * TODO convert the pattern rule to a direct XPath and |
| 1714 * compute directly instead of using the pattern matching | 1716 * compute directly instead of using the pattern matching |
| 1715 » * over the full document... | 1717 » * over the full document... |
| 1716 * Check the exact semantic | 1718 * Check the exact semantic |
| 1717 */ | 1719 */ |
| 1718 cur = root; | 1720 cur = root; |
| 1719 while (cur != NULL) { | 1721 while (cur != NULL) { |
| 1720 rule = pattern->rules; | 1722 rule = pattern->rules; |
| 1721 while (rule != NULL) { | 1723 while (rule != NULL) { |
| 1722 if (xmlPatternMatch(rule->pattern, cur) == 1) { | 1724 if (xmlPatternMatch(rule->pattern, cur) == 1) { |
| 1723 test = rule->tests; | 1725 test = rule->tests; |
| 1724 while (test != NULL) { | 1726 while (test != NULL) { |
| 1725 xmlSchematronRunTest(ctxt, test, instance, cur, patt
ern); | 1727 xmlSchematronRunTest(ctxt, test, instance, cur, patt
ern); |
| 1726 test = test->next; | 1728 test = test->next; |
| 1727 } | 1729 } |
| 1728 } | 1730 } |
| 1729 rule = rule->patnext; | 1731 rule = rule->patnext; |
| 1730 } | 1732 } |
| 1731 » » | 1733 |
| 1732 cur = xmlSchematronNextNode(cur); | 1734 cur = xmlSchematronNextNode(cur); |
| 1733 } | 1735 } |
| 1734 pattern = pattern->next; | 1736 pattern = pattern->next; |
| 1735 } | 1737 } |
| 1736 } | 1738 } |
| 1737 return(ctxt->nberrors); | 1739 return(ctxt->nberrors); |
| 1738 } | 1740 } |
| 1739 | 1741 |
| 1740 #ifdef STANDALONE | 1742 #ifdef STANDALONE |
| 1741 int | 1743 int |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 | 1778 |
| 1777 xmlCleanupParser(); | 1779 xmlCleanupParser(); |
| 1778 xmlMemoryDump(); | 1780 xmlMemoryDump(); |
| 1779 | 1781 |
| 1780 return (0); | 1782 return (0); |
| 1781 } | 1783 } |
| 1782 #endif | 1784 #endif |
| 1783 #define bottom_schematron | 1785 #define bottom_schematron |
| 1784 #include "elfgcchack.h" | 1786 #include "elfgcchack.h" |
| 1785 #endif /* LIBXML_SCHEMATRON_ENABLED */ | 1787 #endif /* LIBXML_SCHEMATRON_ENABLED */ |
| OLD | NEW |