Copy all children from 'source' to 'dest', within the context of the specified page. @param page the page which the nodes belong to @param source the node to copy from @param dest the node to copy to @param handleXHTMLAsHTML if true elements from the XHTML namespace are handled as HTML elements inst
(final SgmlPage page, final Node source, final DomNode dest,
final boolean handleXHTMLAsHTML)
| 308 | * DOM elements |
| 309 | */ |
| 310 | private static void copy(final SgmlPage page, final Node source, final DomNode dest, |
| 311 | final boolean handleXHTMLAsHTML) { |
| 312 | final NodeList nodeChildren = source.getChildNodes(); |
| 313 | for (int i = 0; i < nodeChildren.getLength(); i++) { |
| 314 | final Node child = nodeChildren.item(i); |
| 315 | switch (child.getNodeType()) { |
| 316 | case Node.ELEMENT_NODE: |
| 317 | final DomNode childXml = createFrom(page, child, handleXHTMLAsHTML); |
| 318 | dest.appendChild(childXml); |
| 319 | copy(page, child, childXml, handleXHTMLAsHTML); |
| 320 | break; |
| 321 | |
| 322 | case Node.TEXT_NODE: |
| 323 | dest.appendChild(new DomText(page, child.getNodeValue())); |
| 324 | break; |
| 325 | |
| 326 | case Node.CDATA_SECTION_NODE: |
| 327 | dest.appendChild(new DomCDataSection(page, child.getNodeValue())); |
| 328 | break; |
| 329 | |
| 330 | case Node.COMMENT_NODE: |
| 331 | dest.appendChild(new DomComment(page, child.getNodeValue())); |
| 332 | break; |
| 333 | |
| 334 | case Node.PROCESSING_INSTRUCTION_NODE: |
| 335 | dest.appendChild(new DomProcessingInstruction(page, child.getNodeName(), child.getNodeValue())); |
| 336 | break; |
| 337 | |
| 338 | default: |
| 339 | if (LOG.isWarnEnabled()) { |
| 340 | LOG.warn("NodeType " + child.getNodeType() |
| 341 | + " (" + child.getNodeName() + ") is not yet supported."); |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * Search for the namespace URI of the given prefix, starting from the specified element. |
no test coverage detected