* xmlXPathIntersection: * @nodes1: a node-set * @nodes2: a node-set * * Implements the EXSLT - Sets intersection() function: * node-set set:intersection (node-set, node-set) * * Returns a node set comprising the nodes that are within both the * node sets passed as arguments */
| 3547 | * node sets passed as arguments |
| 3548 | */ |
| 3549 | xmlNodeSetPtr |
| 3550 | xmlXPathIntersection (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) { |
| 3551 | xmlNodeSetPtr ret = xmlXPathNodeSetCreate(NULL); |
| 3552 | int i, l1; |
| 3553 | xmlNodePtr cur; |
| 3554 | |
| 3555 | if (ret == NULL) |
| 3556 | return(ret); |
| 3557 | if (xmlXPathNodeSetIsEmpty(nodes1)) |
| 3558 | return(ret); |
| 3559 | if (xmlXPathNodeSetIsEmpty(nodes2)) |
| 3560 | return(ret); |
| 3561 | |
| 3562 | l1 = xmlXPathNodeSetGetLength(nodes1); |
| 3563 | |
| 3564 | for (i = 0; i < l1; i++) { |
| 3565 | cur = xmlXPathNodeSetItem(nodes1, i); |
| 3566 | if (xmlXPathNodeSetContains(nodes2, cur)) { |
| 3567 | if (xmlXPathNodeSetAddUnique(ret, cur) < 0) { |
| 3568 | xmlXPathFreeNodeSet(ret); |
| 3569 | return(NULL); |
| 3570 | } |
| 3571 | } |
| 3572 | } |
| 3573 | return(ret); |
| 3574 | } |
| 3575 | |
| 3576 | /** |
| 3577 | * xmlXPathDistinctSorted: |
nothing calls this directly
no test coverage detected