bool DOMServices::isNodeAfterSibling( const XalanNode& parent, const XalanNode& child1, const XalanNode& child2) { bool isNodeAfterSibling = false; const XalanNode::NodeType child1type = child1.getNodeType(); const XalanNode::NodeType child2type = child2.getNodeType(); if (XalanNode::ATTRIBUTE_NODE != child1type && XalanNode::ATTRIBUTE_NODE == child2type) { // always sort attributes before non-attributes. isNodeAfterSibling = true; } else if (XalanNode::ATTRIBUTE_NODE == child1type && XalanNode::ATTRIBUTE_NODE != child2type) { // always sort attributes before non-attributes. isNodeAfterSibling = false; } else if (XalanNode::ATTRIBUTE_NODE == child1type) { const XalanNamedNodeMap* children = parent.getAttributes(); const XalanSize_t nNodes = children->getLength(); bool found1 = false; bool found2 = false; for (XalanSize_t i = 0; i < nNodes; i++) { const XalanNode* child = children->item(i); if (&child1 == child) { if (found2 == true) { isNodeAfterSibling = true; break; } found1 = true; } else if (&child2 == child) { if (found1 == true) { isNodeAfterSibling = false; break; } found2 = true; } } } else { const XalanNode* child = parent.getFirstChild(); bool found1 = false; bool found2 = false; while (child != 0) { if (&child1 == child) { if (found2 == true) { isNodeAfterSibling = true; break; } found1 = true; } else if (&child2 == child) { if (found1 == true) { isNodeAfterSibling = false; break; } found2 = true; } child = child->getNextSibling(); } assert(found1 != found2); } return isNodeAfterSibling; }