Lines Matching refs:ctxt

221 xmlSchematronPErrMemory(xmlSchematronParserCtxtPtr ctxt,
224 if (ctxt != NULL)
225 ctxt->nberrors++;
232 * @ctxt: the parsing context
242 xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error,
249 if (ctxt != NULL) {
250 ctxt->nberrors++;
251 channel = ctxt->error;
252 data = ctxt->userData;
253 schannel = ctxt->serror;
255 __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP,
269 xmlSchematronVErrMemory(xmlSchematronValidCtxtPtr ctxt,
272 if (ctxt != NULL) {
273 ctxt->nberrors++;
274 ctxt->err = XML_SCHEMAV_INTERNAL;
288 * @ctxt: the schema parsing context
300 xmlSchematronAddTest(xmlSchematronParserCtxtPtr ctxt,
308 if ((ctxt == NULL) || (rule == NULL) || (node == NULL) ||
315 comp = xmlXPathCtxtCompile(ctxt->xctxt, test);
317 xmlSchematronPErr(ctxt, node,
326 xmlSchematronPErrMemory(ctxt, "allocating schema test", node);
373 * @ctxt: the schema parsing context
384 xmlSchematronAddRule(xmlSchematronParserCtxtPtr ctxt, xmlSchematronPtr schema,
391 if ((ctxt == NULL) || (schema == NULL) || (node == NULL) ||
398 pattern = xmlPatterncompile(context, ctxt->dict, XML_PATTERN_XPATH,
399 ctxt->namespaces);
401 xmlSchematronPErr(ctxt, node,
409 xmlSchematronPErrMemory(ctxt, "allocating schema rule", node);
467 * @ctxt: the schema parsing context
477 xmlSchematronAddPattern(xmlSchematronParserCtxtPtr ctxt,
482 if ((ctxt == NULL) || (schema == NULL) || (node == NULL) || (name == NULL))
487 xmlSchematronPErrMemory(ctxt, "allocating schema pattern", node);
526 * @ctxt: a schema validation context
533 xmlSchematronNewSchematron(xmlSchematronParserCtxtPtr ctxt)
539 xmlSchematronPErrMemory(ctxt, "allocating schema", NULL);
543 ret->dict = ctxt->dict;
697 * @ctxt: the schema parser context
702 xmlSchematronFreeParserCtxt(xmlSchematronParserCtxtPtr ctxt)
704 if (ctxt == NULL)
706 if (ctxt->doc != NULL && !ctxt->preserve)
707 xmlFreeDoc(ctxt->doc);
708 if (ctxt->xctxt != NULL) {
709 xmlXPathFreeContext(ctxt->xctxt);
711 if (ctxt->namespaces != NULL)
712 xmlFree((char **) ctxt->namespaces);
713 xmlDictFree(ctxt->dict);
714 xmlFree(ctxt);
720 * @ctxt: the schema parser context
727 xmlSchematronPushInclude(xmlSchematronParserCtxtPtr ctxt,
730 if (ctxt->includes == NULL) {
731 ctxt->maxIncludes = 10;
732 ctxt->includes = (xmlNodePtr *)
733 xmlMalloc(ctxt->maxIncludes * 2 * sizeof(xmlNodePtr));
734 if (ctxt->includes == NULL) {
739 ctxt->nbIncludes = 0;
740 } else if (ctxt->nbIncludes + 2 >= ctxt->maxIncludes) {
744 xmlRealloc(ctxt->includes, ctxt->maxIncludes * 4 *
751 ctxt->includes = tmp;
752 ctxt->maxIncludes *= 2;
754 ctxt->includes[2 * ctxt->nbIncludes] = cur;
755 ctxt->includes[2 * ctxt->nbIncludes + 1] = (xmlNodePtr) doc;
756 ctxt->nbIncludes++;
761 * @ctxt: the schema parser context
769 xmlSchematronPopInclude(xmlSchematronParserCtxtPtr ctxt)
774 if (ctxt->nbIncludes <= 0)
776 ctxt->nbIncludes--;
777 doc = (xmlDocPtr) ctxt->includes[2 * ctxt->nbIncludes + 1];
778 ret = ctxt->includes[2 * ctxt->nbIncludes];
783 return(xmlSchematronPopInclude(ctxt));
790 * @ctxt: the schema parser context
797 xmlSchematronAddNamespace(xmlSchematronParserCtxtPtr ctxt,
800 if (ctxt->namespaces == NULL) {
801 ctxt->maxNamespaces = 10;
802 ctxt->namespaces = (const xmlChar **)
803 xmlMalloc(ctxt->maxNamespaces * 2 * sizeof(const xmlChar *));
804 if (ctxt->namespaces == NULL) {
809 ctxt->nbNamespaces = 0;
810 } else if (ctxt->nbNamespaces + 2 >= ctxt->maxNamespaces) {
814 xmlRealloc((xmlChar **) ctxt->namespaces, ctxt->maxNamespaces * 4 *
821 ctxt->namespaces = tmp;
822 ctxt->maxNamespaces *= 2;
824 ctxt->namespaces[2 * ctxt->nbNamespaces] =
825 xmlDictLookup(ctxt->dict, ns, -1);
826 ctxt->namespaces[2 * ctxt->nbNamespaces + 1] =
827 xmlDictLookup(ctxt->dict, prefix, -1);
828 ctxt->nbNamespaces++;
829 ctxt->namespaces[2 * ctxt->nbNamespaces] = NULL;
830 ctxt->namespaces[2 * ctxt->nbNamespaces + 1] = NULL;
836 * @ctxt: a schema validation context
842 xmlSchematronParseRule(xmlSchematronParserCtxtPtr ctxt,
854 if ((ctxt == NULL) || (rule == NULL)) return;
858 xmlSchematronPErr(ctxt, rule,
864 xmlSchematronPErr(ctxt, rule,
871 ruleptr = xmlSchematronAddRule(ctxt, ctxt->schema, pattern,
886 xmlSchematronPErr(ctxt, cur,
891 xmlSchematronPErr(ctxt, cur,
900 testptr = xmlSchematronAddTest(ctxt, XML_SCHEMATRON_ASSERT,
909 xmlSchematronPErr(ctxt, cur,
914 xmlSchematronPErr(ctxt, cur,
923 testptr = xmlSchematronAddTest(ctxt, XML_SCHEMATRON_REPORT,
929 xmlSchematronPErr(ctxt, cur,
938 xmlSchematronPErr(ctxt, rule,
946 * @ctxt: a schema validation context
952 xmlSchematronParsePattern(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr pat)
959 if ((ctxt == NULL) || (pat == NULL)) return;
965 pattern = xmlSchematronAddPattern(ctxt, ctxt->schema, pat, id);
975 xmlSchematronParseRule(ctxt, pattern, cur);
978 xmlSchematronPErr(ctxt, cur,
986 xmlSchematronPErr(ctxt, pat,
995 * @ctxt: a schema validation context
1003 xmlSchematronLoadInclude(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr cur)
1011 if ((ctxt == NULL) || (cur == NULL))
1016 xmlSchematronPErr(ctxt, cur,
1027 xmlSchematronPErr(ctxt, cur,
1035 xmlSchematronPErr(ctxt, cur,
1043 xmlSchematronPushInclude(ctxt, doc, cur);
1061 * @ctxt: a schema validation context
1070 xmlSchematronParse(xmlSchematronParserCtxtPtr ctxt)
1077 if (ctxt == NULL)
1080 ctxt->nberrors = 0;
1085 if (ctxt->URL != NULL) {
1086 doc = xmlReadFile((const char *) ctxt->URL, NULL,
1089 xmlSchematronPErr(ctxt, NULL,
1092 ctxt->URL, NULL);
1095 ctxt->preserve = 0;
1096 } else if (ctxt->buffer != NULL) {
1097 doc = xmlReadMemory(ctxt->buffer, ctxt->size, NULL, NULL,
1100 xmlSchematronPErr(ctxt, NULL,
1107 ctxt->URL = xmlDictLookup(ctxt->dict, BAD_CAST "in_memory_buffer", -1);
1108 ctxt->preserve = 0;
1109 } else if (ctxt->doc != NULL) {
1110 doc = ctxt->doc;
1112 ctxt->preserve = 1;
1114 xmlSchematronPErr(ctxt, NULL,
1126 xmlSchematronPErr(ctxt, (xmlNodePtr) doc,
1136 xmlSchematronPErr(ctxt, root,
1139 ctxt->URL, NULL);
1142 ret = xmlSchematronNewSchematron(ctxt);
1145 ctxt->schema = ret;
1165 xmlSchematronPErr(ctxt, cur,
1170 xmlSchematronPErr(ctxt, cur,
1175 xmlXPathRegisterNs(ctxt->xctxt, prefix, uri);
1176 xmlSchematronAddNamespace(ctxt, prefix, uri);
1188 xmlSchematronParsePattern(ctxt, cur);
1191 xmlSchematronPErr(ctxt, cur,
1199 xmlSchematronPErr(ctxt, root,
1202 ctxt->URL, NULL);
1217 if (ctxt->nberrors != 0) {
1221 ret->namespaces = ctxt->namespaces;
1222 ret->nbNamespaces = ctxt->nbNamespaces;
1223 ctxt->namespaces = NULL;
1236 xmlSchematronGetNode(xmlSchematronValidCtxtPtr ctxt,
1241 if ((ctxt == NULL) || (cur == NULL) || (xpath == NULL))
1244 ctxt->xctxt->doc = cur->doc;
1245 ctxt->xctxt->node = cur;
1246 ret = xmlXPathEval(xpath, ctxt->xctxt);
1260 * @ctxt: the validation context
1267 xmlSchematronReportOutput(xmlSchematronValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
1276 * @ctxt: the validation context
1286 xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
1306 node = xmlSchematronGetNode(ctxt, cur, path);
1354 * @ctxt: the validation context
1363 xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
1365 if ((ctxt == NULL) || (cur == NULL) || (test == NULL))
1368 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) &&
1369 ((ctxt->flags & XML_SCHEMATRON_OUT_XML) == 0) &&
1372 if (ctxt->flags & XML_SCHEMATRON_OUT_XML) {
1392 report = xmlSchematronFormatReport(ctxt, test->node, cur);
1406 xmlSchematronReportOutput(ctxt, cur, &msg[0]);
1414 * @ctxt: the validation context
1420 xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt,
1422 if ((ctxt == NULL) || (pattern == NULL))
1424 if (ctxt->flags & XML_SCHEMATRON_OUT_QUIET)
1426 if (ctxt->flags & XML_SCHEMATRON_OUT_XML) {
1434 xmlSchematronReportOutput(ctxt, NULL, &msg[0]);
1489 * @ctxt: the schema validation context
1494 xmlSchematronFreeValidCtxt(xmlSchematronValidCtxtPtr ctxt)
1496 if (ctxt == NULL)
1498 if (ctxt->xctxt != NULL)
1499 xmlXPathFreeContext(ctxt->xctxt);
1500 if (ctxt->dict != NULL)
1501 xmlDictFree(ctxt->dict);
1502 xmlFree(ctxt);
1542 * @ctxt: the schema validation context
1552 xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
1559 ctxt->xctxt->doc = instance;
1560 ctxt->xctxt->node = cur;
1561 ret = xmlXPathCompiledEval(test->comp, ctxt->xctxt);
1596 ctxt->nberrors++;
1598 ctxt->nberrors++;
1600 xmlSchematronReportSuccess(ctxt, test, cur, !failed);
1607 * @ctxt: the schema validation context
1616 xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
1623 if ((ctxt == NULL) || (ctxt->schema == NULL) ||
1624 (ctxt->schema->rules == NULL) || (instance == NULL))
1626 ctxt->nberrors = 0;
1630 ctxt->nberrors++;
1633 if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) ||
1634 (ctxt->flags == 0)) {
1641 rule = ctxt->schema->rules;
1646 xmlSchematronRunTest(ctxt, test, instance, cur);
1659 pattern = ctxt->schema->patterns;
1662 xmlSchematronReportPattern(ctxt, pattern);
1677 xmlSchematronRunTest(ctxt, test, instance, cur);
1689 return(ctxt->nberrors);