* xmlRelaxNGRemoveRedefine: * @ctxt: the parser context * @URL: the normalized URL * @target: the included target * @name: the define name to eliminate * * Applies the elimination algorithm of 4.7 * * Returns 0 in case of error, 1 in case of success. */
| 1524 | * Returns 0 in case of error, 1 in case of success. |
| 1525 | */ |
| 1526 | static int |
| 1527 | xmlRelaxNGRemoveRedefine(xmlRelaxNGParserCtxtPtr ctxt, |
| 1528 | const xmlChar * URL ATTRIBUTE_UNUSED, |
| 1529 | xmlNodePtr target, const xmlChar * name) |
| 1530 | { |
| 1531 | int found = 0; |
| 1532 | xmlNodePtr tmp, tmp2; |
| 1533 | xmlChar *name2; |
| 1534 | |
| 1535 | tmp = target; |
| 1536 | while (tmp != NULL) { |
| 1537 | tmp2 = tmp->next; |
| 1538 | if ((name == NULL) && (IS_RELAXNG(tmp, "start"))) { |
| 1539 | found = 1; |
| 1540 | xmlUnlinkNode(tmp); |
| 1541 | xmlFreeNode(tmp); |
| 1542 | } else if ((name != NULL) && (IS_RELAXNG(tmp, "define"))) { |
| 1543 | name2 = xmlGetProp(tmp, BAD_CAST "name"); |
| 1544 | xmlRelaxNGNormExtSpace(name2); |
| 1545 | if (name2 != NULL) { |
| 1546 | if (xmlStrEqual(name, name2)) { |
| 1547 | found = 1; |
| 1548 | xmlUnlinkNode(tmp); |
| 1549 | xmlFreeNode(tmp); |
| 1550 | } |
| 1551 | xmlFree(name2); |
| 1552 | } |
| 1553 | } else if (IS_RELAXNG(tmp, "include")) { |
| 1554 | xmlChar *href = NULL; |
| 1555 | xmlRelaxNGDocumentPtr inc = tmp->psvi; |
| 1556 | |
| 1557 | if ((inc != NULL) && (inc->doc != NULL) && |
| 1558 | (inc->doc->children != NULL)) { |
| 1559 | |
| 1560 | if (xmlStrEqual |
| 1561 | (inc->doc->children->name, BAD_CAST "grammar")) { |
| 1562 | if (xmlRelaxNGRemoveRedefine(ctxt, href, |
| 1563 | xmlDocGetRootElement(inc->doc)->children, |
| 1564 | name) == 1) { |
| 1565 | found = 1; |
| 1566 | } |
| 1567 | } |
| 1568 | } |
| 1569 | if (xmlRelaxNGRemoveRedefine(ctxt, URL, tmp->children, name) == 1) { |
| 1570 | found = 1; |
| 1571 | } |
| 1572 | } |
| 1573 | tmp = tmp2; |
| 1574 | } |
| 1575 | return (found); |
| 1576 | } |
| 1577 | |
| 1578 | /** |
| 1579 | * xmlRelaxNGLoadInclude: |
no test coverage detected