本文整理了Java中org.apache.axiom.om.OMXMLParserWrapper
类的一些代码示例,展示了OMXMLParserWrapper
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OMXMLParserWrapper
类的具体详情如下:
包路径:org.apache.axiom.om.OMXMLParserWrapper
类名称:OMXMLParserWrapper
[英]Interface OMXMLParserWrapper
[中]接口OMXMLParserWrapper
代码示例来源:origin: org.apache.neethi/neethi
public OMElement convert(XMLStreamReader s) {
return OMXMLBuilderFactory
.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), s)
.getDocumentElement();
}
代码示例来源:origin: org.paxml/PaxmlCore
/**
* Parse input stream to get document.
* @param in input stream
* @return the document
*/
public static OMDocument getDocument(InputStream in) {
// create the builder
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(in);
// get the root element
OMDocument doc = builder.getDocument();
return doc;
}
/**
代码示例来源:origin: org.apache.axis2/axis2-kernel
/**
* Converts a given inputstream to an OMNode
* The reurned OMNode is fully built if buildAll is true.
* If buildAll is false, the caller is responsible for closing the parser.
*
* @param inputStream
* @param buildAll
* @return OMNode
* @throws javax.xml.stream.XMLStreamException
*
*/
public static OMNode toOM(InputStream inputStream, boolean buildAll) throws XMLStreamException {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(inputStream);
OMNode omNode = builder.getDocumentElement();
if (buildAll) {
omNode.build();
builder.close();
}
return omNode;
}
代码示例来源:origin: apache/axis2-java
/**
* Convert DOM Element into a fully built OMElement
* @param element dom Element
* @return OMElement
* @throws Exception
*/
public static OMElement toOM(Element element) throws Exception {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(element, true);
builder.detach();
return builder.getDocumentElement();
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api
/**
* Simple utility that takes an XMLStreamReader and writes it
* to an XMLStreamWriter
* @param reader
* @param writer
* @throws XMLStreamException
*/
public static void reader2writer(XMLStreamReader reader,
XMLStreamWriter writer)
throws XMLStreamException {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(reader);
try {
OMDocument omDocument = builder.getDocument();
Iterator it = omDocument.getChildren();
while (it.hasNext()) {
OMNode omNode = (OMNode) it.next();
omNode.serializeAndConsume(writer);
}
} finally {
builder.close();
}
}
}
代码示例来源:origin: apache/axis2-java
public OMElement processDocument(InputStream inputStream, String contentType,
MessageContext messageContext) throws AxisFault {
try {
String charSetEncoding = (String) messageContext
.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
// createSOAPModelBuilder takes care of configuring the underlying parser to
// avoid the security issue described in CVE-2010-1632
OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(inputStream,
charSetEncoding);
messageContext.setProperty(Constants.BUILDER, builder);
SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
BuilderUtil
.validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope);
BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument()
.getCharsetEncoding(), envelope.getNamespace().getNamespaceURI());
return envelope;
} catch (IOException e) {
throw AxisFault.makeFault(e);
}
}
代码示例来源:origin: apache/axis2-java
/**
* Close the builders.
*
* @param messageContext
* @throws ServletException
*/
void closeStaxBuilder(MessageContext messageContext) throws ServletException {
if (closeReader && messageContext != null) {
try {
SOAPEnvelope envelope = messageContext.getEnvelope();
if(envelope != null) {
OMXMLParserWrapper builder = envelope.getBuilder();
if (builder != null) {
builder.close();
}
}
} catch (Exception e) {
log.debug(e.toString(), e);
}
}
}
代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom
parser = (XMLStreamReader) builder.getParser();
} catch (Exception e) {
throw new XMLStreamException("problem accessing the parser", e);
代码示例来源:origin: org.apache.axis2/axis2-kernel
public OMElement processDocument(InputStream inputStream, String contentType,
MessageContext messageContext) throws AxisFault {
try {
String charSetEncoding = (String) messageContext
.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
// Apply a detachable inputstream. This can be used later
// to (a) get the length of the incoming message or (b)
// free transport resources.
DetachableInputStream is = new DetachableInputStream(inputStream);
messageContext.setProperty(Constants.DETACHABLE_INPUT_STREAM, is);
// createSOAPModelBuilder takes care of configuring the underlying parser to
// avoid the security issue described in CVE-2010-1632
OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(is,
charSetEncoding);
SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
BuilderUtil
.validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope);
BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument()
.getCharsetEncoding(), envelope.getNamespace().getNamespaceURI());
return envelope;
} catch (IOException e) {
throw AxisFault.makeFault(e);
}
}
代码示例来源:origin: org.apache.axis2/axis2-kernel
optimizedContentType,
isSOAP);
envelope = (SOAPEnvelope) builder.getDocumentElement();
} else {
builder = OMXMLBuilderFactory.createSOAPModelBuilder(mis, charSetEnc);
envelope = (SOAPEnvelope) builder.getDocumentElement();
} finally {
builder.detach();
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-common-impl
setParser((XMLStreamReader) builder.getParser());
} catch (Exception e) {
throw new XMLStreamException("problem accessing the parser. " + e.getMessage(),
代码示例来源:origin: wso2/wso2-synapse
/**
* Returns the parsed xml document.
*
* @param stream input stream of xml string or document needed to be parsed
* @return parsed document
*/
public OMElement getParsedOMElement(InputStream stream) {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(stream);
return builder.getDocumentElement();
}
代码示例来源:origin: org.apache.axis2/axis2-kernel
/**
* Converts a given Reader to an OMNode.
* The reurned OMNode is fully built if buildAll is true.
* If buildAll is false, the caller is responsible for closing the parser.
*
* @param reader
* @param buildAll
* @return OMNode
* @throws XMLStreamException
*/
public static OMNode toOM(Reader reader, boolean buildAll) throws XMLStreamException {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(reader);
OMNode omNode = builder.getDocumentElement();
if (buildAll) {
omNode.build();
builder.close();
}
return omNode;
}
}
代码示例来源:origin: apache/axis2-java
boolean isSOAP = true;
builder = getAttachmentsBuilder(mc, mis, optimizedContentType, isSOAP);
envelope = (SOAPEnvelope) builder.getDocumentElement();
} else {
builder = OMXMLBuilderFactory.createSOAPModelBuilder(mis, charSetEnc);
envelope = (SOAPEnvelope) builder.getDocumentElement();
} finally {
builder.detach();
代码示例来源:origin: org.paxml/paxml-core
/**
* Parse input stream to get document.
*
* @param in
* input stream
* @return the document
*/
public static OMDocument getDocument(final InputStream in) {
// create the builder
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new StAXParserConfiguration() {
@Override
public XMLInputFactory configure(XMLInputFactory factory, StAXDialect dialect) {
return factory;
}
}, in);
// get the root element
OMDocument doc = builder.getDocument();
return doc;
}
代码示例来源:origin: stackoverflow.com
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(stream);
OMElement documentElement = builder.getDocumentElement();
Iterator it = documentElement.getChildrenWithName(new QName("http://namespace", "elementName"));
if (it.hasNext()) {
it.next();
it.remove();
}
代码示例来源:origin: apache/axis2-java
/**
* Converts a given inputstream to an OMNode
* The reurned OMNode is fully built if buildAll is true.
* If buildAll is false, the caller is responsible for closing the parser.
*
* @param inputStream
* @param buildAll
* @return OMNode
* @throws javax.xml.stream.XMLStreamException
*
*/
public static OMNode toOM(InputStream inputStream, boolean buildAll) throws XMLStreamException {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(inputStream);
OMNode omNode = builder.getDocumentElement();
if (buildAll) {
omNode.build();
builder.close();
}
return omNode;
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api
/**
* Loads a document from the given URI.
*
* @param uri the URI of the document to load
* @return Returns the document.
* @throws FunctionCallException if the document could not be loaded
*/
public Object getDocument(String uri)
throws FunctionCallException {
InputStream in = null;
try {
if (uri.indexOf(':') == -1) {
in = new FileInputStream(uri);
} else {
URL url = new URL(uri);
in = url.openStream();
}
return OMXMLBuilderFactory.createOMBuilder(in).getDocument();
} catch (Exception e) {
if (in != null) {
try {
in.close();
} catch (IOException ex) {
// Ignore
}
}
throw new FunctionCallException(e);
}
}
代码示例来源:origin: org.apache.neethi/neethi
public OMElement convert(Element s) {
return OMXMLBuilderFactory.createOMBuilder(new DOMSource(s)).getDocumentElement();
}
}
代码示例来源:origin: org.apache.axis2/axis2-kernel
/**
* Convert DOM Element into a fully built OMElement
* @param element
* @param buildAll if true, full OM tree is immediately built. if false, caller is responsible
* for building the tree and closing the parser.
* @return
* @throws Exception
*/
public static OMElement toOM(Element element, boolean buildAll) throws Exception {
Source source = new DOMSource(element);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Result result = new StreamResult(baos);
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(source, result);
ByteArrayInputStream is = new ByteArrayInputStream(baos.toByteArray());
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(is);
OMElement omElement = builder.getDocumentElement();
if (buildAll) {
omElement.build();
builder.close();
}
return omElement;
}
内容来源于网络,如有侵权,请联系作者删除!