我有一个要转换为CSV格式的XML。我使用Jasper Reports来转换它并使用Jasper Studio来设计JRXML。
这是XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<menu-compare xmlns:mig="http://www..com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www..com">
<menu-info>
<menu type="ons" name="HCOTA"/>
<menu type="ux" name="RTACOF"/>
</menu-info>
<field-details>
<fields existence="both">
<field name="taChrgOffMsg.taChrgOffCrit.funcCode">
<field-type type="ons">
<group-name>cota</group-name>
<page-name>cotacrit</page-name>
<control-type>Combo Box</control-type>
<ui-field>funcCode</ui-field>
<label>FLT000204</label>
<label-desc>Function</label-desc>
<mandatory>Y</mandatory>
</field-type>
<field-type type="ux">
<group-name>Rtacof</group-name>
<page-name>Rtacof_criteria_form</page-name>
<page-name-desc>Transaction A/c. Details</page-name-desc>
<control-type>FinHidden</control-type>
<ui-field>funcCode</ui-field>
<section-structure>group1</section-structure>
<form>criteria</form>
</field-type>
</field>
<field name="taChrgOffMsg.taChrgOffCrit.Acct.foracid">
<field-type type="ons">
<group-name>cota</group-name>
<page-name>cotacrit</page-name>
<control-type>Text Field</control-type>
<ui-field>acctId</ui-field>
<label>FLT000265</label>
<label-desc>A/c. ID</label-desc>
<mandatory>Y</mandatory>
</field-type>
<field-type type="ux">
<group-name>Rtacof</group-name>
<page-name>Rtacof_criteria_form</page-name>
<page-name-desc>Transaction A/c. Details</page-name-desc>
<control-type>FinAccountId</control-type>
<ui-field>acctId$accountId</ui-field>
<label>FLT001251</label>
<label-desc>A/c. ID</label-desc>
<mandatory>Y</mandatory>
<section-structure>group1.section1.subSection1.finRow1.finCell1</section-structure>
<form>criteria</form>
</field-type>
</field>
</fields>
<fields existence="nonMap">
<field>
<field-type type="ons">
<group-name>cota</group-name>
<page-name>cotacrit</page-name>
<control-type>Desc. Label</control-type>
<ui-field>acctCrncy</ui-field>
<label></label>
<mandatory>N</mandatory>
</field-type>
</field>
<field>
<field-type type="ons">
<group-name>cota</group-name>
<page-name>cotacrit</page-name>
<control-type>Desc. Label</control-type>
<ui-field>acctSol</ui-field>
<label></label>
<mandatory>N</mandatory>
</field-type>
</field>
<field>
<field-type type="ons">
<group-name>cota</group-name>
<page-name>cotacrit</page-name>
<control-type>Desc. Label</control-type>
<ui-field>acctName</ui-field>
<label></label>
<mandatory>N</mandatory>
</field-type>
</field>
<field>
<field-type type="ux">
<group-name>Rtacof</group-name>
<page-name>Rtacof_criteria_form</page-name>
<page-name-desc>Transaction A/c. Details</page-name-desc>
<control-type>FinAccountId</control-type>
<ui-field>acctId</ui-field>
<label>FLT001251</label>
<label-desc>A/c. ID</label-desc>
<mandatory>Y</mandatory>
<section-structure>group1.section1.subSection1.finRow1.finCell1</section-structure>
<form>criteria</form>
</field-type>
</field>
<field>
<field-type type="ux">
<group-name>Rtacof</group-name>
<page-name>Rtacof_criteria_form</page-name>
<page-name-desc>Transaction A/c. Details</page-name-desc>
<control-type>FinHidden</control-type>
<ui-field>funcCodeExp</ui-field>
<section-structure>group1</section-structure>
<form>criteria</form>
</field-type>
</field>
<field>
<field-type type="ux">
<group-name>Rtacof</group-name>
<page-name>Rtacof_criteria_form</page-name>
<page-name-desc>Transaction A/c. Details</page-name-desc>
<control-type>FinHidden</control-type>
<ui-field>hchrgeOffAmt</ui-field>
<section-structure>group1</section-structure>
<form>criteria</form>
</field-type>
</field>
</fields>
<fields existence="ux">
<field name="taChrgOffMsg.taChrgOffCrit.Acct.acctName">
<field-type type="ux">
<group-name>Rtacof</group-name>
<page-name>Rtacof_criteria_form</page-name>
<page-name-desc>Transaction A/c. Details</page-name-desc>
<control-type>FinAccountId</control-type>
<ui-field>acctId$accountNameDesc</ui-field>
<label>FLT001251</label>
<label-desc>A/c. ID</label-desc>
<mandatory>Y</mandatory>
<section-structure>group1.section1.subSection1.finRow1.finCell1</section-structure>
<form>criteria</form>
</field-type>
</field>
<field name="taChrgOffMsg.taChrgOffCrit.Acct.crncyCode">
<field-type type="ux">
<group-name>Rtacof</group-name>
<page-name>Rtacof_criteria_form</page-name>
<page-name-desc>Transaction A/c. Details</page-name-desc>
<control-type>FinAccountId</control-type>
<ui-field>acctId$currencyDesc</ui-field>
<label>FLT001251</label>
<label-desc>A/c. ID</label-desc>
<mandatory>Y</mandatory>
<section-structure>group1.section1.subSection1.finRow1.finCell1</section-structure>
<form>criteria</form>
</field-type>
</field>
</fields>
</field-details>
</menu-compare>
我希望CSV格式包含以下列:
ons(field_type) ux(field_type)
fields_existence field_name control-type page-name control-type page-name
fields_exitence分为3个(nonMap,ux和两者),
<field-type type="ons">
下的属性需要属于合并的单元格&#39;,<field-type type="ux">
需要属于合并的单元格&#39; ux&#39;如上所述。
因此,我创建了一个主要报告,其中包含fields_existence
和field_name
以及两个子报告,用于&#39; ons&#39;和&#39; ux&#39;。
主要报告:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version last-->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="New3" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="7eade40b-45a9-4626-bef7-fbcc2d4397a4">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter (5)"/>
<subDataset name="Dataset1" uuid="5c92bcef-d33d-481e-afaa-02aa04792e45">
<queryString>
<![CDATA[]]>
</queryString>
<field name="field_name" class="java.lang.String">
<fieldDescription><![CDATA[@name]]></fieldDescription>
</field>
<field name="control-type-ons" class="java.lang.String">
<fieldDescription><![CDATA[/fields/field/field-type[@type = "ons"]/control-type]]></fieldDescription>
</field>
<field name="control-type-ux" class="java.lang.String">
<fieldDescription><![CDATA[/fields/field/field-type[@type = "ux"]/control-type]]></fieldDescription>
</field>
<field name="control-typee-ons" class="java.lang.String">
<fieldDescription><![CDATA[control-type]]></fieldDescription>
</field>
<field name="control-typee-ux" class="java.lang.String">
<fieldDescription><![CDATA[/fields/field/field-type[@type = "ux"]/control-type]]></fieldDescription>
</field>
<field name="label-desc-ons" class="java.lang.String">
<fieldDescription><![CDATA[/fields/field/field-type[@type = "ons"]/label-desc]]></fieldDescription>
</field>
</subDataset>
<subDataset name="Dataset2" uuid="f8c00177-6263-49fc-b17d-f307080a8539">
<queryString>
<![CDATA[]]>
</queryString>
<field name="control-type_d2_ons" class="java.lang.String">
<fieldDescription><![CDATA[control-type]]></fieldDescription>
</field>
</subDataset>
<queryString language="XPath">
<![CDATA[/menu-compare/field-details/fields]]>
</queryString>
<field name="fields_exists" class="java.lang.String">
<fieldDescription><![CDATA[@existence]]></fieldDescription>
</field>
<field name="field" class="java.lang.String">
<fieldDescription><![CDATA[field]]></fieldDescription>
</field>
<field name="field_1" class="java.lang.String">
<fieldDescription><![CDATA[field]]></fieldDescription>
</field>
<field name="field_2" class="java.lang.String">
<fieldDescription><![CDATA[field]]></fieldDescription>
</field>
<field name="field_3" class="java.lang.String">
<fieldDescription><![CDATA[field]]></fieldDescription>
</field>
<field name="field_4" class="java.lang.String">
<fieldDescription><![CDATA[field]]></fieldDescription>
</field>
<field name="field_5" class="java.lang.String">
<fieldDescription><![CDATA[field]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="73" splitType="Stretch">
<textField>
<reportElement uuid="a7807abf-6697-4dbb-b990-f4a63572c158" x="10" y="30" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA["Map_Type"]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="fe9d6fa6-30c2-4507-867a-f60d872a4002" x="110" y="30" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA["Field-Name"]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="264" splitType="Stretch">
<textField>
<reportElement uuid="3f1e6c53-cb80-4117-9aeb-c5b26b1169c0" x="10" y="10" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{fields_exists}]]></textFieldExpression>
</textField>
<componentElement>
<reportElement uuid="e888d323-d870-4c8d-9826-2930dbafcaa4" x="100" y="10" width="310" height="60"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="Dataset1" uuid="fba9150e-05b0-4c8d-933f-26e4766a1de4">
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}.subDataSource("/fields/field")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="66" width="310">
<textField>
<reportElement uuid="6fb1b0ce-65f2-4c22-aa27-f4083bb535c2" x="10" y="15" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{field_name}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="c1821c08-9cdd-4ab2-81d1-6e7981f755fe" x="100" y="15" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{control-type-ons}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="c5cd28df-0742-4f4b-ae5d-1098b472b5a0" x="200" y="15" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{control-type-ux}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
<subreport>
<reportElement uuid="e57583f2-7163-4c8b-8245-7586cf22491f" x="440" y="20" width="41" height="46"/>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}.subDataSource("/fields/field/field-type")]]></dataSourceExpression>
<subreportExpression><![CDATA["New3_SubReport_Ons.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
SubReport_ONS:这里我正确地获取了数据,填充了下面列出的所有字段属性。但是,当我将它添加到主报告时,没有任何东西被填充。
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version last-->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="New3_SubReport_Ons" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="7d9c4551-de86-4504-9dc0-b7617a01f620">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter (5)"/>
<queryString language="xPath">
<![CDATA[/menu-compare/field-details/fields/field/field-type[@type = "ons"]]]>
</queryString>
<field name="group-name" class="java.lang.String">
<fieldDescription><![CDATA[group-name]]></fieldDescription>
</field>
<field name="page-name" class="java.lang.String">
<fieldDescription><![CDATA[page-name]]></fieldDescription>
</field>
<field name="control-type" class="java.lang.String">
<fieldDescription><![CDATA[control-type]]></fieldDescription>
</field>
<field name="ui-field" class="java.lang.String">
<fieldDescription><![CDATA[ui-field]]></fieldDescription>
</field>
<field name="label" class="java.lang.String">
<fieldDescription><![CDATA[label]]></fieldDescription>
</field>
<field name="label-desc" class="java.lang.String">
<fieldDescription><![CDATA[label-desc]]></fieldDescription>
</field>
<field name="mandatory" class="java.lang.String">
<fieldDescription><![CDATA[mandatory]]></fieldDescription>
</field>
<field name="section-structure" class="java.lang.String">
<fieldDescription><![CDATA[section-structure]]></fieldDescription>
</field>
<field name="form" class="java.lang.String">
<fieldDescription><![CDATA[form]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<columnHeader>
<band height="74" splitType="Stretch">
<textField>
<reportElement uuid="11e36190-331d-492d-b2f8-b6b5e255ad29" x="0" y="30" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA["control-type"]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="d29aaacd-1eb0-4f18-800f-79745afaab6a" x="80" y="30" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA["label-desc"]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="975c7937-8450-4270-a14c-f04906402a8a" x="160" y="30" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA["label"]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="29fd8188-114b-4731-8b44-e1b8b87b5734" x="242" y="30" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA["ui-field"]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="8f51cdc4-c1ce-4337-ab61-f4d43d4646bc" x="320" y="30" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA["group-name"]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="7f31617e-3683-4693-a248-6bebe0f5bdf5" x="400" y="30" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA["page-name"]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="24846d3e-7179-4fc7-91e2-f087b35676ac" x="490" y="30" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA["mandatory"]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement uuid="24c09848-f19d-4954-94d9-f6b1cb95f968" x="0" y="20" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{control-type}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="ab6c2cb7-8591-46e4-900e-4b60e0f08f21" x="80" y="20" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{label-desc}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="ab1ff84a-23b9-44c1-88a6-1c5a9fffaeb5" x="160" y="20" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="acfb12b3-d8e0-4319-9339-182ac90a5e8b" x="242" y="20" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ui-field}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="1e0c29fd-e910-40dc-b67b-57aabcf96726" x="320" y="20" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{group-name}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="f37a62d2-2dfe-4f97-b60e-6fc2cf7e868c" x="400" y="20" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{page-name}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="084363d8-635f-4d8b-b0d2-01dbca4ff39f" x="490" y="20" width="70" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{mandatory}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
答案 0 :(得分:0)
尝试在JasperReports Server上发布报告,然后运行主报告.... 主要的想法是JasperSoft Studio没有给我们准确的报告执行,必须在JasperReports服务器中实现和执行一些主题来检查我们工作的成功与否... 我希望它对你有所帮助,最好的问候。