* xmlExcC14NProcessNamespacesAxis: * @ctx: the C14N context * @node: the current node * * Prints out exclusive canonical namespace axis of the current node to the * buffer from C14N context as follows * * Exclusive XML Canonicalization * http://www.w3.org/TR/xml-exc-c14n * * If the element node is in the XPath subset then output the node in * accordance with Canonical XML except for n
| 698 | * Returns 0 on success or -1 on fail. |
| 699 | */ |
| 700 | static int |
| 701 | xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible) |
| 702 | { |
| 703 | xmlNsPtr ns; |
| 704 | xmlListPtr list; |
| 705 | xmlAttrPtr attr; |
| 706 | int already_rendered; |
| 707 | int has_empty_ns = 0; |
| 708 | int has_visibly_utilized_empty_ns = 0; |
| 709 | int has_empty_ns_in_inclusive_list = 0; |
| 710 | |
| 711 | if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) { |
| 712 | xmlC14NErrParam(ctx); |
| 713 | return (-1); |
| 714 | } |
| 715 | |
| 716 | if(!xmlC14NIsExclusive(ctx)) { |
| 717 | xmlC14NErrParam(ctx); |
| 718 | return (-1); |
| 719 | |
| 720 | } |
| 721 | |
| 722 | /* |
| 723 | * Create a sorted list to store element namespaces |
| 724 | */ |
| 725 | list = xmlListCreate(NULL, xmlC14NNsCompare); |
| 726 | if (list == NULL) { |
| 727 | xmlC14NErrMemory(ctx); |
| 728 | return (-1); |
| 729 | } |
| 730 | |
| 731 | /* |
| 732 | * process inclusive namespaces: |
| 733 | * All namespace nodes appearing on inclusive ns list are |
| 734 | * handled as provided in Canonical XML |
| 735 | */ |
| 736 | if(ctx->inclusive_ns_prefixes != NULL) { |
| 737 | xmlChar *prefix; |
| 738 | int i; |
| 739 | |
| 740 | for (i = 0; ctx->inclusive_ns_prefixes[i] != NULL; ++i) { |
| 741 | prefix = ctx->inclusive_ns_prefixes[i]; |
| 742 | /* |
| 743 | * Special values for namespace with empty prefix |
| 744 | */ |
| 745 | if (xmlStrEqual(prefix, BAD_CAST "#default") |
| 746 | || xmlStrEqual(prefix, BAD_CAST "")) { |
| 747 | prefix = NULL; |
| 748 | has_empty_ns_in_inclusive_list = 1; |
| 749 | } |
| 750 | |
| 751 | ns = xmlSearchNs(cur->doc, cur, prefix); |
| 752 | if((ns != NULL) && !xmlC14NIsXmlNs(ns) && xmlC14NIsVisible(ctx, ns, cur)) { |
| 753 | already_rendered = xmlC14NVisibleNsStackFind(ctx->ns_rendered, ns); |
| 754 | if(visible) { |
| 755 | if (xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur) < 0) { |
| 756 | xmlC14NErrMemory(ctx); |
| 757 | goto error; |
no test coverage detected