Home | History | Annotate | Download | only in libxml2

Lines Matching refs:ctxt

228 xmlSchematronPErrMemory(xmlSchematronParserCtxtPtr ctxt,
231 if (ctxt != NULL)
232 ctxt->nberrors++;
239 * @ctxt: the parsing context
249 xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error,
256 if (ctxt != NULL) {
257 ctxt->nberrors++;
258 channel = ctxt->error;
259 data = ctxt->userData;
260 schannel = ctxt->serror;
262 __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP,
276 xmlSchematronVErrMemory(xmlSchematronValidCtxtPtr ctxt,
279 if (ctxt != NULL) {
280 ctxt->nberrors++;
281 ctxt->err = XML_SCHEMAV_INTERNAL;
295 * @ctxt: the schema parsing context
307 xmlSchematronAddTest(xmlSchematronParserCtxtPtr ctxt,
315 if ((ctxt == NULL) || (rule == NULL) || (node == NULL) ||
322 comp = xmlXPathCtxtCompile(ctxt->xctxt, test);
324 xmlSchematronPErr(ctxt, node,
333 xmlSchematronPErrMemory(ctxt, "allocating schema test", node);
380 * @ctxt: the schema parsing context
391 xmlSchematronAddRule(xmlSchematronParserCtxtPtr ctxt, xmlSchematronPtr schema,
398 if ((ctxt == NULL) || (schema == NULL) || (node == NULL) ||
405 pattern = xmlPatterncompile(context, ctxt->dict, XML_PATTERN_XPATH,
406 ctxt->namespaces);
408 xmlSchematronPErr(ctxt, node,
416 xmlSchematronPErrMemory(ctxt, "allocating schema rule", node);
474 * @ctxt: the schema parsing context
484 xmlSchematronAddPattern(xmlSchematronParserCtxtPtr ctxt,
489 if ((ctxt == NULL) || (schema == NULL) || (node == NULL) || (name == NULL))
494 xmlSchematronPErrMemory(ctxt, "allocating schema pattern", node);
533 * @ctxt: a schema validation context
540 xmlSchematronNewSchematron(xmlSchematronParserCtxtPtr ctxt)
546 xmlSchematronPErrMemory(ctxt, "allocating schema", NULL);
550 ret->dict = ctxt->dict;
704 * @ctxt: the schema parser context
709 xmlSchematronFreeParserCtxt(xmlSchematronParserCtxtPtr ctxt)
711 if (ctxt == NULL)
713 if (ctxt->doc != NULL && !ctxt->preserve)
714 xmlFreeDoc(ctxt->doc);
715 if (ctxt->xctxt != NULL) {
716 xmlXPathFreeContext(ctxt->xctxt);
718 if (ctxt->namespaces != NULL)
719 xmlFree((char **) ctxt->namespaces);
720 xmlDictFree(ctxt->dict);
721 xmlFree(ctxt);
727 * @ctxt: the schema parser context
734 xmlSchematronPushInclude(xmlSchematronParserCtxtPtr ctxt,
737 if (ctxt->includes == NULL) {
738 ctxt->maxIncludes = 10;
739 ctxt->includes = (xmlNodePtr *)
740 xmlMalloc(ctxt->maxIncludes * 2 * sizeof(xmlNodePtr));
741 if (ctxt->includes == NULL) {
746 ctxt->nbIncludes = 0;
747 } else if (ctxt->nbIncludes + 2 >= ctxt->maxIncludes) {
751 xmlRealloc(ctxt->includes, ctxt->maxIncludes * 4 *
758 ctxt->includes = tmp;
759 ctxt->maxIncludes *= 2;
761 ctxt->includes[2 * ctxt->nbIncludes] = cur;
762 ctxt->includes[2 * ctxt->nbIncludes + 1] = (xmlNodePtr) doc;
763 ctxt->nbIncludes++;
768 * @ctxt: the schema parser context
776 xmlSchematronPopInclude(xmlSchematronParserCtxtPtr ctxt)
781 if (ctxt->nbIncludes <= 0)
783 ctxt->nbIncludes--;
784 doc = (xmlDocPtr) ctxt->includes[2 * ctxt->nbIncludes + 1];
785 ret = ctxt->includes[2 * ctxt->nbIncludes];
790 return(xmlSchematronPopInclude(ctxt));
797 * @ctxt: the schema parser context
804 xmlSchematronAddNamespace(xmlSchematronParserCtxtPtr ctxt,
807 if (ctxt->namespaces == NULL) {
808 ctxt->maxNamespaces = 10;
809 ctxt->namespaces = (const xmlChar **)
810 xmlMalloc(ctxt->maxNamespaces * 2 * sizeof(const xmlChar *));
811 if (ctxt->namespaces == NULL) {
816 ctxt->nbNamespaces = 0;
817 } else if (ctxt->nbNamespaces + 2 >= ctxt->maxNamespaces) {
821 xmlRealloc((xmlChar **) ctxt->namespaces, ctxt->maxNamespaces * 4 *
828 ctxt->namespaces = tmp;
829 ctxt->maxNamespaces *= 2;
831 ctxt->namespaces[2 * ctxt->nbNamespaces] =
832 xmlDictLookup(ctxt->dict, ns, -1);
833 ctxt->namespaces[2 * ctxt->nbNamespaces + 1] =
834 xmlDictLookup(ctxt->dict, prefix, -1);
835 ctxt->nbNamespaces++;
836 ctxt->namespaces[2 * ctxt->nbNamespaces] = NULL;
837 ctxt->namespaces[2 * ctxt->nbNamespaces + 1] = NULL;
843 * @ctxt: a schema validation context
849 xmlSchematronParseRule(xmlSchematronParserCtxtPtr ctxt,
861 if ((ctxt == NULL) || (rule == NULL)) return;
865 xmlSchematronPErr(ctxt, rule,
871 xmlSchematronPErr(ctxt, rule,
878 ruleptr = xmlSchematronAddRule(ctxt, ctxt->schema, pattern,
893 xmlSchematronPErr(ctxt, cur,
898 xmlSchematronPErr(ctxt, cur,
907 testptr = xmlSchematronAddTest(ctxt, XML_SCHEMATRON_ASSERT,
916 xmlSchematronPErr(ctxt, cur,
921 xmlSchematronPErr(ctxt, cur,
930 testptr = xmlSchematronAddTest(ctxt, XML_SCHEMATRON_REPORT,
936 xmlSchematronPErr(ctxt, cur,
945 xmlSchematronPErr(ctxt, rule,
953 * @ctxt: a schema validation context
959 xmlSchematronParsePattern(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr pat)
966 if ((ctxt == NULL) || (pat == NULL)) return;
972 pattern = xmlSchematronAddPattern(ctxt, ctxt->schema, pat, id);
982 xmlSchematronParseRule(ctxt, pattern, cur);
985 xmlSchematronPErr(ctxt, cur,
993 xmlSchematronPErr(ctxt, pat,
1002 * @ctxt: a schema validation context
1010 xmlSchematronLoadInclude(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr cur)
1018 if ((ctxt == NULL) || (cur == NULL))
1023 xmlSchematronPErr(ctxt, cur,
1034 xmlSchematronPErr(ctxt, cur,
1042 xmlSchematronPErr(ctxt, cur,
1050 xmlSchematronPushInclude(ctxt, doc, cur);
1068 * @ctxt: a schema validation context
1077 xmlSchematronParse(xmlSchematronParserCtxtPtr ctxt)
1084 if (ctxt == NULL)
1087 ctxt->nberrors = 0;
1092 if (ctxt->URL != NULL) {
1093 doc = xmlReadFile((const char *) ctxt->URL, NULL,
1096 xmlSchematronPErr(ctxt, NULL,
1099 ctxt->URL, NULL);
1102 ctxt->preserve = 0;
1103 } else if (ctxt->buffer != NULL) {
1104 doc = xmlReadMemory(ctxt->buffer, ctxt->size, NULL, NULL,
1107 xmlSchematronPErr(ctxt, NULL,
1114 ctxt->URL = xmlDictLookup(ctxt->dict, BAD_CAST "in_memory_buffer", -1);
1115 ctxt->preserve = 0;
1116 } else if (ctxt->doc != NULL) {
1117 doc = ctxt->doc;
1119 ctxt->preserve = 1;
1121 xmlSchematronPErr(ctxt, NULL,
1133 xmlSchematronPErr(ctxt, (xmlNodePtr) doc,
1143 xmlSchematronPErr(ctxt, root,
1146 ctxt->URL, NULL);
1149 ret = xmlSchematronNewSchematron(ctxt);
1152 ctxt->schema = ret;
1172 xmlSchematronPErr(ctxt, cur,
1177 xmlSchematronPErr(ctxt, cur,
1182 xmlXPathRegisterNs(ctxt->xctxt, prefix, uri);
1183 xmlSchematronAddNamespace(ctxt, prefix, uri);
1195 xmlSchematronParsePattern(ctxt, cur);
1198 xmlSchematronPErr(ctxt, cur,
1206 xmlSchematronPErr(ctxt, root,
1209 ctxt->URL, NULL);
1224 if (ctxt->nberrors != 0) {
1228 ret->namespaces = ctxt->namespaces;
1229 ret->nbNamespaces = ctxt->nbNamespaces;
1230 ctxt->namespaces = NULL;
1243 xmlSchematronGetNode(xmlSchematronValidCtxtPtr ctxt,
1248 if ((ctxt == NULL) || (cur == NULL) || (xpath == NULL))
1251 ctxt->xctxt->doc = cur->doc;
1252 ctxt->xctxt->node = cur;
1253 ret = xmlXPathEval(xpath, ctxt->xctxt);
1267 * @ctxt: the validation context
1274 xmlSchematronReportOutput(xmlSchematronValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
1283 * @ctxt: the validation context
1293 xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
1313 node = xmlSchematronGetNode(ctxt, cur, path);
1361 * @ctxt: the validation context
1370 xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
1372 if ((ctxt == NULL) || (cur == NULL) || (test == NULL))
1375 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) &&
1376 ((ctxt->flags & XML_SCHEMATRON_OUT_XML) == 0) &&
1379 if (ctxt->flags & XML_SCHEMATRON_OUT_XML) {
1399 report = xmlSchematronFormatReport(ctxt, test->node, cur);
1410 if (ctxt->flags & XML_SCHEMATRON_OUT_ERROR) {
1415 if (ctxt != NULL) {
1416 if (ctxt->serror != NULL)
1417 schannel = ctxt->serror;
1419 channel = ctxt->error;
1420 data = ctxt->userData;
1432 xmlSchematronReportOutput(ctxt, cur, &msg[0]);
1444 * @ctxt: the validation context
1450 xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt,
1452 if ((ctxt == NULL) || (pattern == NULL))
1454 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) || (ctxt->flags & XML_SCHEMATRON_OUT_ERROR)) /* Error gives pattern name as part of error */
1456 if (ctxt->flags & XML_SCHEMATRON_OUT_XML) {
1464 xmlSchematronReportOutput(ctxt, NULL, &msg[0]);
1477 * @ctxt: a Schematron validation context
1484 xmlSchematronSetValidStructuredErrors(xmlSchematronValidCtxtPtr ctxt,
1487 if (ctxt == NULL)
1489 ctxt->serror = serror;
1490 ctxt->error = NULL;
1491 ctxt->warning = NULL;
1492 ctxt->userData = ctx;
1539 * @ctxt: the schema validation context
1544 xmlSchematronFreeValidCtxt(xmlSchematronValidCtxtPtr ctxt)
1546 if (ctxt == NULL)
1548 if (ctxt->xctxt != NULL)
1549 xmlXPathFreeContext(ctxt->xctxt);
1550 if (ctxt->dict != NULL)
1551 xmlDictFree(ctxt->dict);
1552 xmlFree(ctxt);
1592 * @ctxt: the schema validation context
1602 xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
1609 ctxt->xctxt->doc = instance;
1610 ctxt->xctxt->node = cur;
1611 ret = xmlXPathCompiledEval(test->comp, ctxt->xctxt);
1646 ctxt->nberrors++;
1648 ctxt->nberrors++;
1650 xmlSchematronReportSuccess(ctxt, test, cur, pattern, !failed);
1657 * @ctxt: the schema validation context
1666 xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
1673 if ((ctxt == NULL) || (ctxt->schema == NULL) ||
1674 (ctxt->schema->rules == NULL) || (instance == NULL))
1676 ctxt->nberrors = 0;
1680 ctxt->nberrors++;
1683 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) ||
1684 (ctxt->flags == 0)) {
1691 rule = ctxt->schema->rules;
1696 xmlSchematronRunTest(ctxt, test, instance, cur, (xmlSchematronPatternPtr)rule->pattern);
1709 pattern = ctxt->schema->patterns;
1712 xmlSchematronReportPattern(ctxt, pattern);
1727 xmlSchematronRunTest(ctxt, test, instance, cur, pattern);
1739 return(ctxt->nberrors);