Search in sources :

Example 16 with OMComment

use of org.apache.axiom.om.OMComment in project webservices-axiom by apache.

the class TestCommentInEpilog method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new StringReader(soapFactory.getDefaultEnvelope() + "<!--comment-->")).getSOAPEnvelope();
    OMNode sibling = envelope.getNextOMSibling();
    assertTrue(sibling instanceof OMComment);
}
Also used : OMNode(org.apache.axiom.om.OMNode) OMComment(org.apache.axiom.om.OMComment) StringReader(java.io.StringReader) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 17 with OMComment

use of org.apache.axiom.om.OMComment in project webservices-axiom by apache.

the class TestCommentInProlog method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPMessage message = SOAPSampleSet.COMMENT_IN_PROLOG.getMessage(spec).getAdapter(SOAPSampleAdapter.class).getSOAPMessage(metaFactory);
    OMNode firstChild = message.getFirstOMChild();
    assertTrue(firstChild instanceof OMComment);
}
Also used : OMNode(org.apache.axiom.om.OMNode) OMComment(org.apache.axiom.om.OMComment) SOAPSampleAdapter(org.apache.axiom.ts.soap.SOAPSampleAdapter) SOAPMessage(org.apache.axiom.soap.SOAPMessage)

Example 18 with OMComment

use of org.apache.axiom.om.OMComment in project webservices-axiom by apache.

the class OMFactoryImpl method importChildNode.

private AxiomChildNode importChildNode(OMNode child) {
    int type = child.getType();
    switch(type) {
        case OMNode.ELEMENT_NODE:
            return importElement((OMElement) child, AxiomElement.class);
        case OMNode.TEXT_NODE:
        case OMNode.SPACE_NODE:
        case OMNode.CDATA_SECTION_NODE:
            {
                OMText text = (OMText) child;
                Object content;
                if (text.isBinary()) {
                    content = new TextContent(text.getContentID(), text.getDataHandler(), text.isOptimized());
                } else {
                    content = text.getText();
                }
                return createAxiomText(null, content, type);
            }
        case OMNode.PI_NODE:
            {
                OMProcessingInstruction pi = (OMProcessingInstruction) child;
                AxiomProcessingInstruction importedPI = createNode(AxiomProcessingInstruction.class);
                importedPI.setTarget(pi.getTarget());
                importedPI.setValue(pi.getValue());
                return importedPI;
            }
        case OMNode.COMMENT_NODE:
            {
                OMComment comment = (OMComment) child;
                AxiomComment importedComment = createNode(AxiomComment.class);
                importedComment.setValue(comment.getValue());
                return importedComment;
            }
        case OMNode.DTD_NODE:
            {
                OMDocType docType = (OMDocType) child;
                AxiomDocType importedDocType = createNode(AxiomDocType.class);
                importedDocType.coreSetRootName(docType.getRootName());
                importedDocType.coreSetPublicId(docType.getPublicId());
                importedDocType.coreSetSystemId(docType.getSystemId());
                importedDocType.coreSetInternalSubset(docType.getInternalSubset());
                return importedDocType;
            }
        case OMNode.ENTITY_REFERENCE_NODE:
            AxiomEntityReference importedEntityRef = createNode(AxiomEntityReference.class);
            importedEntityRef.coreSetName(((OMEntityReference) child).getName());
            return importedEntityRef;
        default:
            throw new IllegalArgumentException("Unsupported node type");
    }
}
Also used : OMProcessingInstruction(org.apache.axiom.om.OMProcessingInstruction) OMDocType(org.apache.axiom.om.OMDocType) AxiomDocType(org.apache.axiom.om.impl.intf.AxiomDocType) AxiomProcessingInstruction(org.apache.axiom.om.impl.intf.AxiomProcessingInstruction) OMComment(org.apache.axiom.om.OMComment) AxiomEntityReference(org.apache.axiom.om.impl.intf.AxiomEntityReference) AxiomComment(org.apache.axiom.om.impl.intf.AxiomComment) OMText(org.apache.axiom.om.OMText) TextContent(org.apache.axiom.om.impl.intf.TextContent)

Example 19 with OMComment

use of org.apache.axiom.om.OMComment in project wso2-synapse by wso2.

the class AbstractMediatorSerializer method serializeComments.

/**
 * Serialize String Comment entries from a List
 *
 * @param parent      OMElement to be updated
 * @param commentList List of comment entries to be serialized
 */
protected void serializeComments(OMElement parent, List<String> commentList) {
    for (String comment : commentList) {
        OMComment commendNode = fac.createOMComment(parent, "comment");
        commendNode.setValue(comment);
        parent.addChild(commendNode);
    }
}
Also used : OMComment(org.apache.axiom.om.OMComment)

Aggregations

OMComment (org.apache.axiom.om.OMComment)19 OMElement (org.apache.axiom.om.OMElement)9 OMNode (org.apache.axiom.om.OMNode)8 OMFactory (org.apache.axiom.om.OMFactory)7 StringReader (java.io.StringReader)4 OMText (org.apache.axiom.om.OMText)4 Iterator (java.util.Iterator)3 OMContainer (org.apache.axiom.om.OMContainer)2 OMDocument (org.apache.axiom.om.OMDocument)2 OMProcessingInstruction (org.apache.axiom.om.OMProcessingInstruction)2 SynapseException (org.apache.synapse.SynapseException)2 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)2 CommentMediator (org.apache.synapse.mediators.builtin.CommentMediator)2 QName (javax.xml.namespace.QName)1 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1 OMDocType (org.apache.axiom.om.OMDocType)1 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)1 AxiomComment (org.apache.axiom.om.impl.intf.AxiomComment)1 AxiomDocType (org.apache.axiom.om.impl.intf.AxiomDocType)1 AxiomEntityReference (org.apache.axiom.om.impl.intf.AxiomEntityReference)1