本文整理汇总了Java中org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement方法的典型用法代码示例。如果您正苦于以下问题:Java StAXOMBuilder.getDocumentElement方法的具体用法?Java StAXOMBuilder.getDocumentElement怎么用?Java StAXOMBuilder.getDocumentElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axiom.om.impl.builder.StAXOMBuilder
的用法示例。
在下文中一共展示了StAXOMBuilder.getDocumentElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOMElement
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
public OMElement getOMElement(String filePath) throws FileNotFoundException,
XMLStreamException {
//if file location =null it taking from the test data directory
OMElement documentElement = null;
FileInputStream inputStream;
File file = new File(filePath);
if (file.exists()) {
inputStream = new FileInputStream(filePath);
XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
//create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
//get the root element (in this case the envelope)
documentElement = builder.getDocumentElement();
}
return documentElement;
}
示例2: parse_xml_string
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
OMElement parse_xml_string(String input_string) {
byte[] ba = input_string.getBytes();
// create the parser
XMLStreamReader parser=null;
try {
parser = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(ba));
} catch (XMLStreamException e) {
assertTrue("Could not create XMLStreamReader from " + "input stream", false);
}
// create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
// get the root element (in this case the envelope)
OMElement documentElement = builder.getDocumentElement();
return documentElement;
}
示例3: parse_xml_string
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
static public OMElement parse_xml_string(String input_string) throws XMLParserException {
byte[] ba = input_string.getBytes();
// create the parser
XMLStreamReader parser=null;
try {
parser = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(ba));
} catch (XMLStreamException e) {
throw new XMLParserException("gov.nist.registry.common2.xml.Parse: Could not create XMLStreamReader from " + "input stream");
}
// create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
// get the root element (in this case the envelope)
OMElement documentElement = builder.getDocumentElement();
return documentElement;
}
示例4: parse_xml
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
public static OMElement parse_xml(InputStream is) throws FactoryConfigurationError, XdsInternalException {
// create the parser
XMLStreamReader parser=null;
try {
parser = XMLInputFactory.newInstance().createXMLStreamReader(is);
} catch (XMLStreamException e) {
throw new XdsInternalException("Could not create XMLStreamReader from InputStream");
}
// create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
// get the root element (in this case the envelope)
OMElement documentElement = builder.getDocumentElement();
if (documentElement == null)
throw new XdsInternalException("No document element");
return documentElement;
}
示例5: test200508ConversionStartingFromAxis2
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
public void test200508ConversionStartingFromAxis2() throws Exception {
XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(EPR200508));
StAXOMBuilder builder = new StAXOMBuilder(parser);
OMElement omElement = builder.getDocumentElement();
EndpointReference axis2EPR =
EndpointReferenceHelper.fromOM(omElement);
W3CEndpointReference jaxwsEPR =
(W3CEndpointReference) EndpointReferenceUtils.convertFromAxis2(axis2EPR, Final.WSA_NAMESPACE);
assertXMLEqual(EPR200508, jaxwsEPR.toString());
EndpointReference axis2Result =
EndpointReferenceUtils.createAxis2EndpointReference("");
String addressingNamespace = EndpointReferenceUtils.convertToAxis2(axis2Result, jaxwsEPR);
OMElement eprElement =
EndpointReferenceHelper.toOM(OMF, axis2Result, ELEMENT200508, addressingNamespace);
assertXMLEqual(EPR200508, eprElement.toString());
}
示例6: startUp
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
public void startUp(ConfigurationContext configctx,
AxisService service) {
try {
String tempDir = System.getProperty("java.io.tmpdir");
File tempFile = new File(tempDir);
File libFile = new File(tempFile, "library.xml");
OMElement libraryElement;
boolean noFile = true;
if (!libFile.exists()) {
//Service starting at the first time or user has clean the temp.dir
Parameter allBooks = service.getParameter(LibraryConstants.ALL_BOOK);
libraryElement = allBooks.getParameterElement();
} else {
InputStream in = new FileInputStream(libFile);
XMLStreamReader xmlReader = StAXUtils
.createXMLStreamReader(in);
StAXOMBuilder staxOMBuilder = new StAXOMBuilder(xmlReader);
libraryElement = staxOMBuilder.getDocumentElement();
noFile = false;
}
processOmelemnt(libraryElement, service, noFile);
} catch (Exception exception) {
log.info(exception);
}
}
示例7: buildOMElement
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
/**
* Method to build an AXIOM element from a byte stream.
*
* @param content the stream of bytes.
* @return the AXIOM element.
* @throws GovernanceException if the operation failed.
*/
public static OMElement buildOMElement(byte[] content) throws RegistryException {
XMLStreamReader parser;
try {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.IS_COALESCING, new Boolean(true));
parser = factory.createXMLStreamReader(new StringReader(
RegistryUtils.decodeBytes(content)));
} catch (XMLStreamException e) {
String msg = "Error in initializing the parser to build the OMElement.";
log.error(msg, e);
throw new GovernanceException(msg, e);
}
//create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
//get the root element (in this case the envelope)
return builder.getDocumentElement();
}
示例8: load
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
/**
* Converts the bpel process definition to an omElement which is how the AXIS2 Object Model (AXIOM) represents an
* XML
* element
*
* @param bpelStr bpel process definition needed to create the SVG
* @return omElement
*/
public OMElement load(String bpelStr) {
try {
/*Creates a new instance of the XmlStreamReader class for the specified String input i.e. the bpel
process definition
using the StringReader class which enables you to turn an ordinary String into a Reader.
This is useful if you have data as a String but need to pass that String to a component that only
accepts a Reader.
*/
parser = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(bpelStr));
/*The instance of XmlStreamReader created is passed to the StAXOMBuilder which produces a pure XML
infoset compliant object
model which conatins the bpel process definition
*/
builder = new StAXOMBuilder(parser);
//The XML object created by the StAXOMBuilder is used to build an OMElement that is added to an existing
// OM tree
bpelElement = builder.getDocumentElement();
//OmElement containing the bpel process definition is returned
return bpelElement;
} catch (XMLStreamException e) {
log.error("XMLStreamReader creation failed", e);
throw new NullPointerException("Document Element is NULL");
}
}
示例9: buildOMElement
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
public OMElement buildOMElement(String content) throws GovernanceException {
XMLStreamReader parser;
try {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.IS_COALESCING, new Boolean(true));
parser = factory.createXMLStreamReader(new StringReader(content));
} catch (XMLStreamException e) {
String msg = "Error in initializing the parser to build the OMElement.";
log.error(msg, e);
throw new GovernanceException(msg, e);
}
//create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
//get the root element (in this case the envelope)
return builder.getDocumentElement();
}
示例10: buildOMElement
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
public static OMElement buildOMElement(byte[] content) throws MetadataException {
XMLStreamReader parser;
try {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.IS_COALESCING, new Boolean(true));
parser = factory.createXMLStreamReader(new StringReader(
RegistryUtils.decodeBytes(content)));
} catch (Exception e) {
String msg = "Error in initializing the parser to build the OMElement.";
log.error(msg, e);
throw new MetadataException("", e);
}
//create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
//get the root element (in this case the envelope)
return builder.getDocumentElement();
}
示例11: sendError
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
private void sendError(HttpServletResponse res, Object object, String serviceName) throws EventHandlerException {
try {
// setup the response
res.setContentType("text/xml");
String xmlResults= SoapSerializer.serialize(object);
XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlResults));
StAXOMBuilder resultsBuilder = new StAXOMBuilder(xmlReader);
OMElement resultSer = resultsBuilder.getDocumentElement();
// create the response soap
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope resEnv = factory.createSOAPEnvelope();
SOAPBody resBody = factory.createSOAPBody();
OMElement errMsg = factory.createOMElement(new QName((serviceName != null ? serviceName : "") + "Response"));
errMsg.addChild(resultSer.getFirstElement());
resBody.addChild(errMsg);
resEnv.addChild(resBody);
// The declareDefaultNamespace method doesn't work see (https://issues.apache.org/jira/browse/AXIS2-3156)
// so the following doesn't work:
// resService.declareDefaultNamespace(ModelService.TNS);
// instead, create the xmlns attribute directly:
OMAttribute defaultNS = factory.createOMAttribute("xmlns", null, ModelService.TNS);
errMsg.addAttribute(defaultNS);
// log the response message
if (Debug.verboseOn()) {
try {
Debug.logInfo("Response Message:\n" + resEnv + "\n", module);
} catch (Throwable t) {
}
}
resEnv.serialize(res.getOutputStream());
res.getOutputStream().flush();
} catch (Exception e) {
throw new EventHandlerException(e.getMessage(), e);
}
}
示例12: addDynamicEndPoint
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
public boolean addDynamicEndPoint(String key, DataHandler dh)
throws EndpointAdminEndpointAdminException, IOException, XMLStreamException {
XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream());
//create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
OMElement endPointElem = builder.getDocumentElement();
return endpointAdminStub.addDynamicEndpoint(key, endPointElem.toString());
}
示例13: read
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
public static OMElement read(String filePath) throws FileNotFoundException,
XMLStreamException {
OMElement documentElement = null;
FileInputStream inputStream = null;
XMLStreamReader parser = null;
File file = new File(filePath);
try {
inputStream = new FileInputStream(filePath);
parser = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
//create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
//get the root element
documentElement = builder.getDocumentElement();
documentElement.build();
} finally {
if (parser != null) {
parser.close();
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
//ignore
}
}
}
return documentElement;
}
示例14: addTask
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
public void addTask(DataHandler dh)
throws TaskManagementException, IOException, XMLStreamException {
XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream());
//create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
OMElement scheduleTaskElem = builder.getDocumentElement();
// scheduleTaskElem.setText("test");
taskAdminStub.addTaskDescription(scheduleTaskElem);
}
示例15: addPriorityMediator
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
public void addPriorityMediator(String name, DataHandler dh)
throws IOException, XMLStreamException {
XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream());
StAXOMBuilder builder = new StAXOMBuilder(parser);
OMElement messageProcessorElem = builder.getDocumentElement();
priorityMediationAdmin.add(name, messageProcessorElem);
}