Home | History | Annotate | Download | only in libxml2

Lines Matching refs:ctxt

226 xmlSchematronPErrMemory(xmlSchematronParserCtxtPtr ctxt,
229 if (ctxt != NULL)
230 ctxt->nberrors++;
237 * @ctxt: the parsing context
247 xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error,
254 if (ctxt != NULL) {
255 ctxt->nberrors++;
256 channel = ctxt->error;
257 data = ctxt->userData;
258 schannel = ctxt->serror;
260 __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP,
274 xmlSchematronVErrMemory(xmlSchematronValidCtxtPtr ctxt,
277 if (ctxt != NULL) {
278 ctxt->nberrors++;
279 ctxt->err = XML_SCHEMAV_INTERNAL;
293 * @ctxt: the schema parsing context
305 xmlSchematronAddTest(xmlSchematronParserCtxtPtr ctxt,
313 if ((ctxt == NULL) || (rule == NULL) || (node == NULL) ||
320 comp = xmlXPathCtxtCompile(ctxt->xctxt, test);
322 xmlSchematronPErr(ctxt, node,
331 xmlSchematronPErrMemory(ctxt, "allocating schema test", node);
378 * @ctxt: the schema parsing context
389 xmlSchematronAddRule(xmlSchematronParserCtxtPtr ctxt, xmlSchematronPtr schema,
396 if ((ctxt == NULL) || (schema == NULL) || (node == NULL) ||
403 pattern = xmlPatterncompile(context, ctxt->dict, XML_PATTERN_XPATH,
404 ctxt->namespaces);
406 xmlSchematronPErr(ctxt, node,
414 xmlSchematronPErrMemory(ctxt, "allocating schema rule", node);
472 * @ctxt: the schema parsing context
482 xmlSchematronAddPattern(xmlSchematronParserCtxtPtr ctxt,
487 if ((ctxt == NULL) || (schema == NULL) || (node == NULL) || (name == NULL))
492 xmlSchematronPErrMemory(ctxt, "allocating schema pattern", node);
531 * @ctxt: a schema validation context
538 xmlSchematronNewSchematron(xmlSchematronParserCtxtPtr ctxt)
544 xmlSchematronPErrMemory(ctxt, "allocating schema", NULL);
548 ret->dict = ctxt->dict;
702 * @ctxt: the schema parser context
707 xmlSchematronFreeParserCtxt(xmlSchematronParserCtxtPtr ctxt)
709 if (ctxt == NULL)
711 if (ctxt->doc != NULL && !ctxt->preserve)
712 xmlFreeDoc(ctxt->doc);
713 if (ctxt->xctxt != NULL) {
714 xmlXPathFreeContext(ctxt->xctxt);
716 if (ctxt->namespaces != NULL)
717 xmlFree((char **) ctxt->namespaces);
718 xmlDictFree(ctxt->dict);
719 xmlFree(ctxt);
725 * @ctxt: the schema parser context
732 xmlSchematronPushInclude(xmlSchematronParserCtxtPtr ctxt,
735 if (ctxt->includes == NULL) {
736 ctxt->maxIncludes = 10;
737 ctxt->includes = (xmlNodePtr *)
738 xmlMalloc(ctxt->maxIncludes * 2 * sizeof(xmlNodePtr));
739 if (ctxt->includes == NULL) {
744 ctxt->nbIncludes = 0;
745 } else if (ctxt->nbIncludes + 2 >= ctxt->maxIncludes) {
749 xmlRealloc(ctxt->includes, ctxt->maxIncludes * 4 *
756 ctxt->includes = tmp;
757 ctxt->maxIncludes *= 2;
759 ctxt->includes[2 * ctxt->nbIncludes] = cur;
760 ctxt->includes[2 * ctxt->nbIncludes + 1] = (xmlNodePtr) doc;
761 ctxt->nbIncludes++;
766 * @ctxt: the schema parser context
774 xmlSchematronPopInclude(xmlSchematronParserCtxtPtr ctxt)
779 if (ctxt->nbIncludes <= 0)
781 ctxt->nbIncludes--;
782 doc = (xmlDocPtr) ctxt->includes[2 * ctxt->nbIncludes + 1];
783 ret = ctxt->includes[2 * ctxt->nbIncludes];
788 return(xmlSchematronPopInclude(ctxt));
795 * @ctxt: the schema parser context
802 xmlSchematronAddNamespace(xmlSchematronParserCtxtPtr ctxt,
805 if (ctxt->namespaces == NULL) {
806 ctxt->maxNamespaces = 10;
807 ctxt->namespaces = (const xmlChar **)
808 xmlMalloc(ctxt->maxNamespaces * 2 * sizeof(const xmlChar *));
809 if (ctxt->namespaces == NULL) {
814 ctxt->nbNamespaces = 0;
815 } else if (ctxt->nbNamespaces + 2 >= ctxt->maxNamespaces) {
819 xmlRealloc((xmlChar **) ctxt->namespaces, ctxt->maxNamespaces * 4 *
826 ctxt->namespaces = tmp;
827 ctxt->maxNamespaces *= 2;
829 ctxt->namespaces[2 * ctxt->nbNamespaces] =
830 xmlDictLookup(ctxt->dict, ns, -1);
831 ctxt->namespaces[2 * ctxt->nbNamespaces + 1] =
832 xmlDictLookup(ctxt->dict, prefix, -1);
833 ctxt->nbNamespaces++;
834 ctxt->namespaces[2 * ctxt->nbNamespaces] = NULL;
835 ctxt->namespaces[2 * ctxt->nbNamespaces + 1] = NULL;
841 * @ctxt: a schema validation context
847 xmlSchematronParseRule(xmlSchematronParserCtxtPtr ctxt,
859 if ((ctxt == NULL) || (rule == NULL)) return;
863 xmlSchematronPErr(ctxt, rule,
869 xmlSchematronPErr(ctxt, rule,
876 ruleptr = xmlSchematronAddRule(ctxt, ctxt->schema, pattern,
891 xmlSchematronPErr(ctxt, cur,
896 xmlSchematronPErr(ctxt, cur,
905 testptr = xmlSchematronAddTest(ctxt, XML_SCHEMATRON_ASSERT,
914 xmlSchematronPErr(ctxt, cur,
919 xmlSchematronPErr(ctxt, cur,
928 testptr = xmlSchematronAddTest(ctxt, XML_SCHEMATRON_REPORT,
934 xmlSchematronPErr(ctxt, cur,
943 xmlSchematronPErr(ctxt, rule,
951 * @ctxt: a schema validation context
957 xmlSchematronParsePattern(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr pat)
964 if ((ctxt == NULL) || (pat == NULL)) return;
970 pattern = xmlSchematronAddPattern(ctxt, ctxt->schema, pat, id);
980 xmlSchematronParseRule(ctxt, pattern, cur);
983 xmlSchematronPErr(ctxt, cur,
991 xmlSchematronPErr(ctxt, pat,
1000 * @ctxt: a schema validation context
1008 xmlSchematronLoadInclude(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr cur)
1016 if ((ctxt == NULL) || (cur == NULL))
1021 xmlSchematronPErr(ctxt, cur,
1032 xmlSchematronPErr(ctxt, cur,
1040 xmlSchematronPErr(ctxt, cur,
1048 xmlSchematronPushInclude(ctxt, doc, cur);
1066 * @ctxt: a schema validation context
1075 xmlSchematronParse(xmlSchematronParserCtxtPtr ctxt)
1082 if (ctxt == NULL)
1085 ctxt->nberrors = 0;
1090 if (ctxt->URL != NULL) {
1091 doc = xmlReadFile((const char *) ctxt->URL, NULL,
1094 xmlSchematronPErr(ctxt, NULL,
1097 ctxt->URL, NULL);
1100 ctxt->preserve = 0;
1101 } else if (ctxt->buffer != NULL) {
1102 doc = xmlReadMemory(ctxt->buffer, ctxt->size, NULL, NULL,
1105 xmlSchematronPErr(ctxt, NULL,
1112 ctxt->URL = xmlDictLookup(ctxt->dict, BAD_CAST "in_memory_buffer", -1);
1113 ctxt->preserve = 0;
1114 } else if (ctxt->doc != NULL) {
1115 doc = ctxt->doc;
1117 ctxt->preserve = 1;
1119 xmlSchematronPErr(ctxt, NULL,
1131 xmlSchematronPErr(ctxt, (xmlNodePtr) doc,
1141 xmlSchematronPErr(ctxt, root,
1144 ctxt->URL, NULL);
1147 ret = xmlSchematronNewSchematron(ctxt);
1150 ctxt->schema = ret;
1170 xmlSchematronPErr(ctxt, cur,
1175 xmlSchematronPErr(ctxt, cur,
1180 xmlXPathRegisterNs(ctxt->xctxt, prefix, uri);
1181 xmlSchematronAddNamespace(ctxt, prefix, uri);
1193 xmlSchematronParsePattern(ctxt, cur);
1196 xmlSchematronPErr(ctxt, cur,
1204 xmlSchematronPErr(ctxt, root,
1207 ctxt->URL, NULL);
1222 if (ctxt->nberrors != 0) {
1226 ret->namespaces = ctxt->namespaces;
1227 ret->nbNamespaces = ctxt->nbNamespaces;
1228 ctxt->namespaces = NULL;
1241 xmlSchematronGetNode(xmlSchematronValidCtxtPtr ctxt,
1246 if ((ctxt == NULL) || (cur == NULL) || (xpath == NULL))
1249 ctxt->xctxt->doc = cur->doc;
1250 ctxt->xctxt->node = cur;
1251 ret = xmlXPathEval(xpath, ctxt->xctxt);
1265 * @ctxt: the validation context
1272 xmlSchematronReportOutput(xmlSchematronValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
1281 * @ctxt: the validation context
1291 xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
1311 node = xmlSchematronGetNode(ctxt, cur, path);
1359 * @ctxt: the validation context
1368 xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
1370 if ((ctxt == NULL) || (cur == NULL) || (test == NULL))
1373 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) &&
1374 ((ctxt->flags & XML_SCHEMATRON_OUT_XML) == 0) &&
1377 if (ctxt->flags & XML_SCHEMATRON_OUT_XML) {
1397 report = xmlSchematronFormatReport(ctxt, test->node, cur);
1408 if (ctxt->flags & XML_SCHEMATRON_OUT_ERROR) {
1413 if (ctxt != NULL) {
1414 if (ctxt->serror != NULL)
1415 schannel = ctxt->serror;
1417 channel = ctxt->error;
1418 data = ctxt->userData;
1430 xmlSchematronReportOutput(ctxt, cur, &msg[0]);
1442 * @ctxt: the validation context
1448 xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt,
1450 if ((ctxt == NULL) || (pattern == NULL))
1452 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) || (ctxt->flags & XML_SCHEMATRON_OUT_ERROR)) /* Error gives pattern name as part of error */
1454 if (ctxt->flags & XML_SCHEMATRON_OUT_XML) {
1462 xmlSchematronReportOutput(ctxt, NULL, &msg[0]);
1475 * @ctxt: a Schematron validation context
1482 xmlSchematronSetValidStructuredErrors(xmlSchematronValidCtxtPtr ctxt,
1485 if (ctxt == NULL)
1487 ctxt->serror = serror;
1488 ctxt->error = NULL;
1489 ctxt->warning = NULL;
1490 ctxt->userData = ctx;
1537 * @ctxt: the schema validation context
1542 xmlSchematronFreeValidCtxt(xmlSchematronValidCtxtPtr ctxt)
1544 if (ctxt == NULL)
1546 if (ctxt->xctxt != NULL)
1547 xmlXPathFreeContext(ctxt->xctxt);
1548 if (ctxt->dict != NULL)
1549 xmlDictFree(ctxt->dict);
1550 xmlFree(ctxt);
1590 * @ctxt: the schema validation context
1600 xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
1607 ctxt->xctxt->doc = instance;
1608 ctxt->xctxt->node = cur;
1609 ret = xmlXPathCompiledEval(test->comp, ctxt->xctxt);
1644 ctxt->nberrors++;
1646 ctxt->nberrors++;
1648 xmlSchematronReportSuccess(ctxt, test, cur, pattern, !failed);
1655 * @ctxt: the schema validation context
1664 xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
1671 if ((ctxt == NULL) || (ctxt->schema == NULL) ||
1672 (ctxt->schema->rules == NULL) || (instance == NULL))
1674 ctxt->nberrors = 0;
1678 ctxt->nberrors++;
1681 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) ||
1682 (ctxt->flags == 0)) {
1689 rule = ctxt->schema->rules;
1694 xmlSchematronRunTest(ctxt, test, instance, cur, (xmlSchematronPatternPtr)rule->pattern);
1707 pattern = ctxt->schema->patterns;
1710 xmlSchematronReportPattern(ctxt, pattern);
1725 xmlSchematronRunTest(ctxt, test, instance, cur, pattern);
1737 return(ctxt->nberrors);