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

Function xmlSchemaCleanupDoc

ThirdParty/libxml2/vtklibxml2/xmlschemas.c:9509–9575  ·  view source on GitHub ↗

* xmlSchemaCleanupDoc: * @ctxt: a schema validation context * @node: the root of the document. * * removes unwanted nodes in a schemas document tree */

Source from the content-addressed store, hash-verified

9507 * removes unwanted nodes in a schemas document tree
9508 */
9509static void
9510xmlSchemaCleanupDoc(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr root)
9511{
9512 xmlNodePtr delete, cur;
9513
9514 if ((ctxt == NULL) || (root == NULL)) return;
9515
9516 /*
9517 * Remove all the blank text nodes
9518 */
9519 delete = NULL;
9520 cur = root;
9521 while (cur != NULL) {
9522 if (delete != NULL) {
9523 xmlUnlinkNode(delete);
9524 xmlFreeNode(delete);
9525 delete = NULL;
9526 }
9527 if (cur->type == XML_TEXT_NODE) {
9528 if (IS_BLANK_NODE(cur)) {
9529 if (xmlNodeGetSpacePreserve(cur) != 1) {
9530 delete = cur;
9531 }
9532 }
9533 } else if ((cur->type != XML_ELEMENT_NODE) &&
9534 (cur->type != XML_CDATA_SECTION_NODE)) {
9535 delete = cur;
9536 goto skip_children;
9537 }
9538
9539 /*
9540 * Skip to next node
9541 */
9542 if (cur->children != NULL) {
9543 if ((cur->children->type != XML_ENTITY_DECL) &&
9544 (cur->children->type != XML_ENTITY_REF_NODE) &&
9545 (cur->children->type != XML_ENTITY_NODE)) {
9546 cur = cur->children;
9547 continue;
9548 }
9549 }
9550 skip_children:
9551 if (cur->next != NULL) {
9552 cur = cur->next;
9553 continue;
9554 }
9555
9556 do {
9557 cur = cur->parent;
9558 if (cur == NULL)
9559 break;
9560 if (cur == root) {
9561 cur = NULL;
9562 break;
9563 }
9564 if (cur->next != NULL) {
9565 cur = cur->next;
9566 break;

Callers 1

xmlSchemaAddSchemaDocFunction · 0.85

Calls 3

xmlUnlinkNodeFunction · 0.85
xmlFreeNodeFunction · 0.85
xmlNodeGetSpacePreserveFunction · 0.85

Tested by

no test coverage detected