Java 类net.sf.jasperreports.engine.util.xml.JRXPathExecuterUtils 实例源码

项目:PDFReporter-Studio    文件:XMLDataAdapterDescriptor.java   
/**
 * Returns the list of fields provided by an XML document and the related
 * query.
 * 
 * @param doc
 *          the W3C XML document
 * @param jConfig
 *          the JasperReports configuration instance
 * @param jDataset
 *          the current dataset
 * @return the list of fields
 * @throws JRException
 */
protected List<JRDesignField> getFieldsFromDocument(Document doc, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException {
    JRXPathExecuterFactory xPathExecuterFactory = JRXPathExecuterUtils.getXPathExecuterFactory(jConfig);
    JRXPathExecuter xPathExecuter = xPathExecuterFactory.getXPathExecuter();
    NodeList nodes = xPathExecuter.selectNodeList(doc, jDataset.getQuery().getText());
    LinkedHashMap<String, JRDesignField> fieldsMap = new LinkedHashMap<String, JRDesignField>();
    for (int nIdx = 0; nIdx < nodes.getLength(); nIdx++) {
        Node currNode = nodes.item(nIdx);
        findDirectChildrenAttributes(currNode,fieldsMap,"");
        if(currNode.getNodeType() == Node.ELEMENT_NODE) {
            NodeList childNodes = currNode.getChildNodes();
            findChildFields(childNodes, fieldsMap,"");
        }
    }
    return new ArrayList<JRDesignField>(fieldsMap.values());
}
项目:ireport-fork    文件:XMLFieldMappingEditor.java   
/** Creates new form XMLFieldMappingEditor 
 * @param rqd 
 */
public XMLFieldMappingEditor(ReportQueryDialog rqd) {
    initComponents();
    try {
        Thread.currentThread().setContextClassLoader( IReportManager.getReportClassLoader());
        xpathExecuter = JRXPathExecuterUtils.getXPathExecuter(IRLocalJasperReportsContext.getInstance());
    } catch (JRException ex) {
       ex.printStackTrace();
    }
    this.reportQueryDialog = rqd;
    jTree1.setCellRenderer(new XMLDocumentTreeCellRenderer(this));
    jTree1.setTransferHandler( new XMLTreeTransfertHandler( this ));
    setXpathExpression( rqd.getQueryEditorPane().getText() );
    updateView();

    //applyI18n();
}
项目:jasperreports    文件:JRXmlDataSource.java   
/**
 * Creates the data source by parsing the xml document from the given file.
 * An additional XPath expression specifies the select criteria that produces the 
 * nodes (records) for the data source.
 * 
 * @param document the document
 * @param selectExpression the XPath select expression
 * @throws JRException if the data source cannot be created
 */
public JRXmlDataSource(
    JasperReportsContext jasperReportsContext,
    Document document, 
    String selectExpression
    ) throws JRException 
{
    this.document = document;
    this.selectExpression = selectExpression;

    this.xPathExecuter = JRXPathExecuterUtils.getXPathExecuter(jasperReportsContext);

    moveFirst();
}