mirror of
https://github.com/jezhiggins/arabica
synced 2024-12-26 21:58:39 +01:00
fixed sorting bug when reverse sorting a nodeset which includes the root node
This commit is contained in:
parent
68301e8878
commit
a049a72c08
1 changed files with 9 additions and 1 deletions
|
@ -114,6 +114,14 @@ std::vector<unsigned int> node_position(const DOM::Node<string_type, string_adap
|
|||
return pos;
|
||||
} // node_position
|
||||
|
||||
template<class string_type, class string_adaptor>
|
||||
DOM::Node<string_type, string_adaptor> get_owner_document(const DOM::Node<string_type, string_adaptor>& node)
|
||||
{
|
||||
if(node.getNodeType() == DOM::Node_base::DOCUMENT_NODE)
|
||||
return node;
|
||||
return node.getOwnerDocument();
|
||||
} // get_owner_document
|
||||
|
||||
template<class string_type, class string_adaptor>
|
||||
int compareNodes(const DOM::Node<string_type, string_adaptor>& lhs,
|
||||
const DOM::Node<string_type, string_adaptor>& rhs)
|
||||
|
@ -122,7 +130,7 @@ int compareNodes(const DOM::Node<string_type, string_adaptor>& lhs,
|
|||
return 0;
|
||||
|
||||
// different documents
|
||||
if(lhs.getOwnerDocument() != rhs.getOwnerDocument())
|
||||
if(get_owner_document(lhs) != get_owner_document(rhs))
|
||||
return (lhs.getOwnerDocument().unlying_impl() < rhs.getOwnerDocument().unlying_impl()) ? 1 : -1;
|
||||
|
||||
// ok, nodes belong to the same document, but do they belong to the document itself, or a document fragment,
|
||||
|
|
Loading…
Reference in a new issue