本文整理汇总了Java中org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Java StAXOMBuilder.getDocument方法的具体用法?Java StAXOMBuilder.getDocument怎么用?Java StAXOMBuilder.getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axiom.om.impl.builder.StAXOMBuilder
的用法示例。
在下文中一共展示了StAXOMBuilder.getDocument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: outputTo
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
/**
* outputTo the writer.
*
* @param writer -- the output of the converter
*/
public void outputTo(XMLStreamWriter writer) throws XMLStreamException {
// Using OM to convert the reader to a writer. This seems to be
// the safest way to make the conversion, and it promotes code re-use.
StAXOMBuilder builder = new StAXOMBuilder(reader);
OMDocument omDocument = builder.getDocument();
Iterator it = omDocument.getChildren();
while (it.hasNext()) {
OMNode omNode = (OMNode)it.next();
// TODO Using serialize and consume
// caused an axiom bug...falling back to serialize
// (which is less performant due to om caching)
//omNode.serializeAndConsume(writer);
omNode.serialize(writer);
}
// Close the reader if marked to do so
if (closeReader) {
if (log.isDebugEnabled()) {
log.debug("closing reader, builder: " + JavaUtils.stackToString());
}
reader.close();
}
}
示例2: createXMLObjectModel
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
private void createXMLObjectModel(String jrxmlFile) throws FileNotFoundException,
XMLStreamException, ReportingException {
XMLInputFactory xif = XMLInputFactory.newInstance();
xif.setProperty("javax.xml.stream.isCoalescing", true);
InputStream jrxmlInputStream = getJrxmlFileContent(jrxmlFile);
XMLStreamReader reader = xif.createXMLStreamReader(jrxmlInputStream);
StAXOMBuilder builder = new StAXOMBuilder(reader);
document = builder.getDocument();
}
示例3: retrieveXMLObject
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
private void retrieveXMLObject(String jrxmlFile) throws FileNotFoundException,
XMLStreamException, ReportingException {
XMLInputFactory xif = XMLInputFactory.newInstance();
InputStream jrxmlInputStream = getJrxmlFileContent(jrxmlFile);
XMLStreamReader reader = xif.createXMLStreamReader(jrxmlInputStream);
xif.setProperty("javax.xml.stream.isCoalescing", false);
StAXOMBuilder builder = new StAXOMBuilder(reader);
document = builder.getDocument();
}
示例4: getSubreportNames
import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入方法依赖的package包/类
private String[] getSubreportNames(String template) throws XMLStreamException, JaxenException {
InputStream is = new ByteArrayInputStream(template.getBytes());
XMLInputFactory xif = XMLInputFactory.newInstance();
XMLStreamReader reader = xif.createXMLStreamReader(is);
StAXOMBuilder builder = new StAXOMBuilder(reader);
OMDocument document = builder.getDocument();
OMElement documentElement = document.getOMDocumentElement();
AXIOMXPath xpathExpression = new AXIOMXPath("//a:subreport");
xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports");
List nodeList = xpathExpression.selectNodes(documentElement);
ArrayList<String> repNames = new ArrayList<String>();
if(nodeList == null | nodeList.size()<1){
return null;
}
else {
for(Object obj : nodeList){
if(obj instanceof OMElement){
OMElement subReport = (OMElement)obj;
Iterator iterator = subReport.getChildrenWithLocalName("subreportExpression");
OMElement element = (OMElement)iterator.next();
String reportName = element.getText();
reportName = reportName.replaceAll("\\{", "");
reportName = reportName.replaceAll("\\}", "");
reportName = reportName.replaceAll("\\$P", "");
reportName = reportName.replaceAll("\\$F", "");
repNames.add(reportName);
}
}
String[] names = new String[repNames.size()];
names = repNames.toArray(names);
return names;
}
}