Skip to content

Commit f23e0ff

Browse files
committed
Document, Node: Recognize HTML documents
Documents created with htmlReadDoc() have xmlElementType == XML_HTML_DOCUMENT_NODE. Handle that type like the XML_DOCUMENT_NODE type. htmlDoc* is an alias for xmlDoc*. Fixes #23
1 parent 4caece9 commit f23e0ff

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

libxml++/document.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void find_wrappers(xmlNode* node, NodeMap& node_map)
5656
case XML_ATTRIBUTE_DECL:
5757
case XML_ENTITY_DECL:
5858
case XML_DOCUMENT_NODE:
59+
case XML_HTML_DOCUMENT_NODE:
5960
has_attributes = false;
6061
break;
6162
default:
@@ -102,6 +103,7 @@ void remove_found_wrappers(xmlNode* node, NodeMap& node_map)
102103
case XML_ATTRIBUTE_DECL:
103104
case XML_ENTITY_DECL:
104105
case XML_DOCUMENT_NODE:
106+
case XML_HTML_DOCUMENT_NODE:
105107
has_attributes = false;
106108
break;
107109
default:
@@ -457,6 +459,7 @@ int Document::process_xinclude(bool generate_xinclude_nodes, bool fixup_base_uri
457459
delete reinterpret_cast<Dtd*>(node);
458460
break;
459461
case XML_DOCUMENT_NODE:
462+
case XML_HTML_DOCUMENT_NODE:
460463
delete reinterpret_cast<Document*>(node);
461464
break;
462465
default:

libxml++/nodes/node.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,9 @@ ustring Node::eval_to_string(const ustring& xpath, const PrefixNsMap& namespaces
449449

450450
ustring Node::get_namespace_prefix() const
451451
{
452-
if(impl_->type == XML_DOCUMENT_NODE || impl_->type == XML_ENTITY_DECL)
452+
if(impl_->type == XML_DOCUMENT_NODE ||
453+
impl_->type == XML_HTML_DOCUMENT_NODE ||
454+
impl_->type == XML_ENTITY_DECL)
453455
{
454456
//impl_ is actually of type xmlDoc or xmlEntity, instead of just xmlNode.
455457
//libxml does not always use GObject-style inheritance, so xmlDoc and
@@ -475,6 +477,7 @@ ustring Node::get_namespace_prefix() const
475477
ustring Node::get_namespace_uri() const
476478
{
477479
if(impl_->type == XML_DOCUMENT_NODE ||
480+
impl_->type == XML_HTML_DOCUMENT_NODE ||
478481
impl_->type == XML_ENTITY_DECL ||
479482
impl_->type == XML_ATTRIBUTE_DECL)
480483
{
@@ -591,6 +594,7 @@ void Node::create_wrapper(xmlNode* node)
591594
break;
592595
}
593596
case XML_DOCUMENT_NODE:
597+
case XML_HTML_DOCUMENT_NODE:
594598
{
595599
// do nothing. For Documents it's the wrapper that is the owner.
596600
break;
@@ -639,6 +643,7 @@ void Node::free_wrappers(xmlNode* node)
639643
node->_private = nullptr;
640644
return;
641645
case XML_DOCUMENT_NODE:
646+
case XML_HTML_DOCUMENT_NODE:
642647
//Do not free now. The Document is usually the one who owns the caller.
643648
return;
644649
default:

0 commit comments

Comments
 (0)