use of org.apache.axiom.om.impl.dom.CommentImpl in project ballerina by ballerina-lang.
the class BXMLItem method copy.
/**
* {@inheritDoc}
*/
@Override
public BXMLItem copy() {
OMNode clonedNode = null;
switch(nodeType) {
case ELEMENT:
clonedNode = ((OMElement) omNode).cloneOMElement();
break;
case TEXT:
TextImpl text = new TextImpl();
text.setTextContent(((OMText) omNode).getText());
clonedNode = text;
break;
case COMMENT:
CommentImpl comment = new CommentImpl();
comment.setTextContent(((OMComment) omNode).getValue());
clonedNode = comment;
break;
case PI:
OMProcessingInstructionImpl pi = new OMProcessingInstructionImpl();
pi.setTarget(((OMProcessingInstruction) omNode).getTarget());
pi.setValue(((OMProcessingInstruction) omNode).getValue());
clonedNode = pi;
break;
default:
clonedNode = omNode;
break;
}
// adding the document element as parent, to get xpPaths work
OMDocument doc = new OMDocumentImpl();
doc.addChild(clonedNode);
return new BXMLItem(clonedNode);
}
Aggregations