* xmlXPathNodeTrailingSorted: * @nodes: a node-set, sorted by document order * @node: a node * * Implements the EXSLT - Sets trailing() function: * node-set set:trailing (node-set, node-set) * * Returns the nodes in @nodes that follow @node in document order, * @nodes if @node is NULL or an empty node-set if @nodes * doesn't contain @node */
| 3792 | * doesn't contain @node |
| 3793 | */ |
| 3794 | xmlNodeSetPtr |
| 3795 | xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes, xmlNodePtr node) { |
| 3796 | int i, l; |
| 3797 | xmlNodePtr cur; |
| 3798 | xmlNodeSetPtr ret; |
| 3799 | |
| 3800 | if (node == NULL) |
| 3801 | return(nodes); |
| 3802 | |
| 3803 | ret = xmlXPathNodeSetCreate(NULL); |
| 3804 | if (ret == NULL) |
| 3805 | return(ret); |
| 3806 | if (xmlXPathNodeSetIsEmpty(nodes) || |
| 3807 | (!xmlXPathNodeSetContains(nodes, node))) |
| 3808 | return(ret); |
| 3809 | |
| 3810 | l = xmlXPathNodeSetGetLength(nodes); |
| 3811 | for (i = l - 1; i >= 0; i--) { |
| 3812 | cur = xmlXPathNodeSetItem(nodes, i); |
| 3813 | if (cur == node) |
| 3814 | break; |
| 3815 | if (xmlXPathNodeSetAddUnique(ret, cur) < 0) { |
| 3816 | xmlXPathFreeNodeSet(ret); |
| 3817 | return(NULL); |
| 3818 | } |
| 3819 | } |
| 3820 | xmlXPathNodeSetSort(ret); /* bug 413451 */ |
| 3821 | return(ret); |
| 3822 | } |
| 3823 | |
| 3824 | /** |
| 3825 | * xmlXPathNodeTrailing: |
no test coverage detected