Search in sources :

Example 1 with OMProcessingInstructionImpl

use of org.apache.axiom.om.impl.llom.OMProcessingInstructionImpl 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);
}
Also used : OMNode(org.apache.axiom.om.OMNode) OMDocumentImpl(org.apache.axiom.om.impl.llom.OMDocumentImpl) CommentImpl(org.apache.axiom.om.impl.dom.CommentImpl) OMProcessingInstructionImpl(org.apache.axiom.om.impl.llom.OMProcessingInstructionImpl) TextImpl(org.apache.axiom.om.impl.dom.TextImpl) OMDocument(org.apache.axiom.om.OMDocument)

Aggregations

OMDocument (org.apache.axiom.om.OMDocument)1 OMNode (org.apache.axiom.om.OMNode)1 CommentImpl (org.apache.axiom.om.impl.dom.CommentImpl)1 TextImpl (org.apache.axiom.om.impl.dom.TextImpl)1 OMDocumentImpl (org.apache.axiom.om.impl.llom.OMDocumentImpl)1 OMProcessingInstructionImpl (org.apache.axiom.om.impl.llom.OMProcessingInstructionImpl)1