Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Commit

Permalink
domutils: support clone from CDATASection DOM nodes
Browse files Browse the repository at this point in the history
Closes issue #92
  • Loading branch information
pabigot committed Jan 27, 2018
1 parent 8c6646d commit 817e4c1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pyxb/utils/domutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,15 @@ def _deepClone (self, node, docnode):
return clone_node
if node.COMMENT_NODE == node.nodeType:
return docnode.createComment(node.data)
if node.CDATA_SECTION_NODE == node.nodeType:
# Technically Python DOM allows the nodeValue to be None, though
# the `data` property of a CDATASection object is supposed to only
# be a string. Do the check anyway, so if a user encounters this
# we can provide a solution that meets the actual need rather than
# silently substituting something unexpected.
if isinstance(node.nodeValue, six.string_types):
return docnode.createTextNode(node.data)
raise ValueError('DOM node from non-text CDATA not supported in clone', node.nodeValue)
raise ValueError('DOM node not supported in clone', node)

def cloneIntoImplementation (self, node):
Expand Down

0 comments on commit 817e4c1

Please sign in to comment.