* xmlC14NProcessElementNode: * @ctx: the pointer to C14N context object * @cur: the node to process * @visible: this node is visible * @all_parents_visible: whether all the parents of this node are visible * * Canonical XML v 1.0 (http://www.w3.org/TR/xml-c14n) * * Element Nodes * If the element is not in the node-set, then the result is obtained * by processing the namespace axis,
| 1426 | * Returns non-negative value on success or negative value on fail |
| 1427 | */ |
| 1428 | static int |
| 1429 | xmlC14NProcessElementNode(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible) |
| 1430 | { |
| 1431 | int ret; |
| 1432 | xmlC14NVisibleNsStack state; |
| 1433 | int parent_is_doc = 0; |
| 1434 | |
| 1435 | if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) { |
| 1436 | xmlC14NErrParam(ctx); |
| 1437 | return (-1); |
| 1438 | } |
| 1439 | |
| 1440 | /* |
| 1441 | * Check relative relative namespaces: |
| 1442 | * implementations of XML canonicalization MUST report an operation |
| 1443 | * failure on documents containing relative namespace URIs. |
| 1444 | */ |
| 1445 | if (xmlC14NCheckForRelativeNamespaces(ctx, cur) < 0) |
| 1446 | return (-1); |
| 1447 | |
| 1448 | /* |
| 1449 | * Save ns_rendered stack position |
| 1450 | */ |
| 1451 | memset(&state, 0, sizeof(state)); |
| 1452 | xmlC14NVisibleNsStackSave(ctx->ns_rendered, &state); |
| 1453 | |
| 1454 | if (visible) { |
| 1455 | if (ctx->parent_is_doc) { |
| 1456 | /* save this flag into the stack */ |
| 1457 | parent_is_doc = ctx->parent_is_doc; |
| 1458 | ctx->parent_is_doc = 0; |
| 1459 | ctx->pos = XMLC14N_INSIDE_DOCUMENT_ELEMENT; |
| 1460 | } |
| 1461 | xmlOutputBufferWriteString(ctx->buf, "<"); |
| 1462 | |
| 1463 | if ((cur->ns != NULL) && (xmlStrlen(cur->ns->prefix) > 0)) { |
| 1464 | xmlOutputBufferWriteString(ctx->buf, |
| 1465 | (const char *) cur->ns->prefix); |
| 1466 | xmlOutputBufferWriteString(ctx->buf, ":"); |
| 1467 | } |
| 1468 | xmlOutputBufferWriteString(ctx->buf, (const char *) cur->name); |
| 1469 | } |
| 1470 | |
| 1471 | if (!xmlC14NIsExclusive(ctx)) { |
| 1472 | ret = xmlC14NProcessNamespacesAxis(ctx, cur, visible); |
| 1473 | } else { |
| 1474 | ret = xmlExcC14NProcessNamespacesAxis(ctx, cur, visible); |
| 1475 | } |
| 1476 | if (ret < 0) |
| 1477 | return (-1); |
| 1478 | /* todo: shouldn't this go to "visible only"? */ |
| 1479 | if(visible) { |
| 1480 | xmlC14NVisibleNsStackShift(ctx->ns_rendered); |
| 1481 | } |
| 1482 | |
| 1483 | ret = xmlC14NProcessAttrsAxis(ctx, cur, visible); |
| 1484 | if (ret < 0) |
| 1485 | return (-1); |
no test coverage detected