当前位置: 首页>>代码示例>>Java>>正文


Java OMNode.TEXT_NODE属性代码示例

本文整理汇总了Java中org.apache.axiom.om.OMNode.TEXT_NODE属性的典型用法代码示例。如果您正苦于以下问题:Java OMNode.TEXT_NODE属性的具体用法?Java OMNode.TEXT_NODE怎么用?Java OMNode.TEXT_NODE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.axiom.om.OMNode的用法示例。


在下文中一共展示了OMNode.TEXT_NODE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processExpressions

static void processExpressions(ITag tag, IParserContext context) {
	if (!(tag instanceof ExpressionTag)) {
		// make sure all text nodes are converted to <expression> tags
		OMElement ele = context.getElement();

		for (OMNode child : AxiomUtils.getNodes(ele)) {
			if (child.getType() == OMNode.TEXT_NODE) {
				OMText textNode = (OMText) child;
				String text = textNode.getText();

				if (StringUtils.isNotBlank(text)) {
					OMElement expTag = createExpressionTag(text, ele.getLineNumber());
					child.insertSiblingAfter(expTag);
					child.detach();
				}
			}
		}
	}
}
 
开发者ID:niuxuetao,项目名称:paxml,代码行数:19,代码来源:AbstractTagFactory.java

示例2: getInnerXml

private String getInnerXml(OMElement ele) {
    StringBuilder sb = new StringBuilder();
    for (Iterator<OMNode> it = ele.getChildren(); it.hasNext();) {
        OMNode node = it.next();
        if (node.getType() == OMNode.TEXT_NODE) {
            sb.append(((OMText) node).getText());
        } else if (node.getType() == OMNode.COMMENT_NODE) {
            sb.append("<!--").append(((OMComment) node).getValue()).append("-->");
        } else {
            sb.append(node.toString());
        }
    }
    return sb.toString();
}
 
开发者ID:niuxuetao,项目名称:paxml,代码行数:14,代码来源:LiteralTagFactory.java

示例3: getValue

/**
 * Returns the the value of the immediate child of this <code>Node</code> object if a child
 * exists and its value is text.
 *
 * @return a <code>String</code> with the text of the immediate child of this <code>Node</code>
 *         object if (1) there is a child and (2) the child is a <code>Text</code> object;
 *         <code>null</code> otherwise
 */
public String getValue() {
    if (element.getType() == OMNode.TEXT_NODE) {
        return element.getText();
    } else if (element.getType() == OMNode.ELEMENT_NODE) {
        final OMNode firstOMChild = element.getFirstOMChild();
        if (firstOMChild instanceof TextImpl) {
            return ((TextImpl)firstOMChild).getData();
        } else if (firstOMChild instanceof SOAPElementImpl) {
            return ((SOAPElementImpl)firstOMChild).getValue();
        }
    }
    return null;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:21,代码来源:SOAPElementImpl.java

示例4: toDOM

public static Element toDOM(OMElement element, Document doc, boolean deepNS) {
    final Element domElement = doc.createElementNS(element.getQName().getNamespaceURI(),
                                                   element.getQName().getLocalPart());

    if (deepNS) {
        NSContext nscontext = new NSContext();
        buildNScontext(nscontext, element);
        DOMUtils.injectNamespaces(domElement,nscontext);
    } else {
        if (element.getAllDeclaredNamespaces() != null) {
            for (Iterator i = element.getAllDeclaredNamespaces(); i.hasNext(); ) {
                OMNamespace omns = (OMNamespace)i.next();
                if (omns.getPrefix().equals("")) {
                    domElement.setAttributeNS(DOMUtils.NS_URI_XMLNS, "xmlns",
                                              omns.getNamespaceURI() == null ? "" :
                                                                        omns.getNamespaceURI());
                }
                else {
                    domElement.setAttributeNS(DOMUtils.NS_URI_XMLNS, "xmlns:"+ omns.getPrefix(),
                                              omns.getNamespaceURI());
                }
            }

        }
    }

    for (Iterator i = element.getAllAttributes(); i.hasNext();) {
        final OMAttribute attr = (OMAttribute) i.next();
        Attr newAttr;
        if (attr.getNamespace() != null) {
            newAttr = doc.createAttributeNS(attr.getNamespace().getNamespaceURI(),
                                            attr.getLocalName());
        } else {
            newAttr = doc.createAttributeNS(null,attr.getLocalName());
        }

        newAttr.appendChild(doc.createTextNode(attr.getAttributeValue()));
        domElement.setAttributeNodeNS(newAttr);

        // Case of qualified attribute values, we're forced to add corresponding namespace declaration manually...
        int colonIdx = attr.getAttributeValue().indexOf(":");
        if (colonIdx > 0) {
            OMNamespace attrValNs = element.findNamespaceURI(attr.getAttributeValue().
                                                                    substring(0, colonIdx));
            if(attrValNs!=null) {
                domElement.setAttributeNS(DOMUtils.NS_URI_XMLNS, "xmlns:"+ attrValNs.getPrefix(),
                                          attrValNs.getNamespaceURI());
            }
        }
    }

    for (Iterator i = element.getChildren(); i.hasNext();) {
        OMNode omn = (OMNode) i.next();

        switch (omn.getType()) {
        case OMNode.CDATA_SECTION_NODE:
            domElement.appendChild(doc.createCDATASection(((OMText)omn).getText()));
            break;
        case OMNode.TEXT_NODE:
            domElement.appendChild(doc.createTextNode(((OMText)omn).getText()));
            break;
        case OMNode.ELEMENT_NODE:
            domElement.appendChild(toDOM((OMElement)omn,doc, false));
            break;
        }

    }

    return domElement;

}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:71,代码来源:OMUtils.java


注:本文中的org.apache.axiom.om.OMNode.TEXT_NODE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。