MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlRelaxNGProcessExternalRef

Function xmlRelaxNGProcessExternalRef

ThirdParty/libxml2/vtklibxml2/relaxng.c:4643–4718  ·  view source on GitHub ↗

* xmlRelaxNGProcessExternalRef: * @ctxt: the parser context * @node: the externalRef node * * Process and compile an externalRef node * * Returns the xmlRelaxNGDefinePtr or NULL in case of error */

Source from the content-addressed store, hash-verified

4641 * Returns the xmlRelaxNGDefinePtr or NULL in case of error
4642 */
4643static xmlRelaxNGDefinePtr
4644xmlRelaxNGProcessExternalRef(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
4645{
4646 xmlRelaxNGDocumentPtr docu;
4647 xmlNodePtr root, tmp;
4648 xmlChar *ns;
4649 int newNs = 0, oldflags;
4650 xmlRelaxNGDefinePtr def;
4651
4652 docu = node->psvi;
4653 if (docu != NULL) {
4654 def = xmlRelaxNGNewDefine(ctxt, node);
4655 if (def == NULL)
4656 return (NULL);
4657 def->type = XML_RELAXNG_EXTERNALREF;
4658
4659 if (docu->content == NULL) {
4660 /*
4661 * Then do the parsing for good
4662 */
4663 root = xmlDocGetRootElement(docu->doc);
4664 if (root == NULL) {
4665 xmlRngPErr(ctxt, node, XML_RNGP_EXTERNALREF_EMTPY,
4666 "xmlRelaxNGParse: %s is empty\n", ctxt->URL,
4667 NULL);
4668 return (NULL);
4669 }
4670 /*
4671 * ns transmission rules
4672 */
4673 ns = xmlGetProp(root, BAD_CAST "ns");
4674 if (ns == NULL) {
4675 tmp = node;
4676 while ((tmp != NULL) && (tmp->type == XML_ELEMENT_NODE)) {
4677 ns = xmlGetProp(tmp, BAD_CAST "ns");
4678 if (ns != NULL) {
4679 break;
4680 }
4681 tmp = tmp->parent;
4682 }
4683 if (ns != NULL) {
4684 xmlSetProp(root, BAD_CAST "ns", ns);
4685 newNs = 1;
4686 xmlFree(ns);
4687 }
4688 } else {
4689 xmlFree(ns);
4690 }
4691
4692 /*
4693 * Parsing to get a precompiled schemas.
4694 */
4695 oldflags = ctxt->flags;
4696 ctxt->flags |= XML_RELAXNG_IN_EXTERNALREF;
4697 docu->schema = xmlRelaxNGParseDocument(ctxt, root);
4698 ctxt->flags = oldflags;
4699 if ((docu->schema != NULL) &&
4700 (docu->schema->topgrammar != NULL)) {

Callers 1

xmlRelaxNGParsePatternFunction · 0.85

Calls 7

xmlRelaxNGNewDefineFunction · 0.85
xmlDocGetRootElementFunction · 0.85
xmlGetPropFunction · 0.85
xmlSetPropFunction · 0.85
xmlRelaxNGParseDocumentFunction · 0.85
xmlUnsetPropFunction · 0.85

Tested by

no test coverage detected