使用XSLT从XML生成EXCEL

时间:2014-06-26 08:43:39

标签: java xml excel xslt

我有以下XML。想要使用XSLT生成EXCEL。但我对此并不熟悉,也不知道如何从XML生成XLS以及如何将其用于XSLT。

XML -

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mig:menu-compare xmlns:mig="http://www.com/migration/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www..com/migration">
    <mig:menu-info>
        <mig:menu type="one" name="HCOTA"/>
        <mig:menu type="two" name="RTACOF"/>
    </mig:menu-info>
    <mig:field-details>
        <mig:fields existence="one">
            <mig:field name="taChrgOffMsg.taChrgOffCrit.funcCode">
                <mig:field-type type="one">
                    <mig:group-name>cota</mig:group-name>
                    <mig:page-name>cotacrit</mig:page-name>
                    <mig:control-type>Combo Box</mig:control-type>
                    <mig:ui-field>funcCode</mig:ui-field>
                    <mig:label>FLT000204</mig:label>
                    <mig:mandatory>Y</mig:mandatory>
                </mig:field-type>
            </mig:field>
            <mig:field>
                <mig:field-type type="one">
                    <mig:group-name>cota</mig:group-name>
                    <mig:page-name>cotares</mig:page-name>
                    <mig:control-type>Button</mig:control-type>
                    <mig:ui-field>endMenu</mig:ui-field>
                    <mig:label></mig:label>
                    <mig:mandatory></mig:mandatory>
                </mig:field-type>
            </mig:field>
        </mig:fields>
        <mig:fields existence="both">
            <mig:field name="taChrgOffMsg.taChrgOffCrit.Acct.foracid">
                <mig:field-type type="one">
                    <mig:group-name>cota</mig:group-name>
                    <mig:page-name>cotacrit</mig:page-name>
                    <mig:control-type>Text Field</mig:control-type>
                    <mig:ui-field>acctId</mig:ui-field>
                    <mig:label>FLT000265</mig:label>
                    <mig:mandatory>Y</mig:mandatory>
                </mig:field-type>
                <mig:field-type type="two">
                    <mig:group-name>Rtacof</mig:group-name>
                    <mig:page-name>Rtacof_criteria_form</mig:page-name>
                    <mig:control-type>FinAccountId</mig:control-type>
                    <mig:ui-field>acctId$accountId</mig:ui-field>
                    <mig:label>FLT001251</mig:label>
                    <mig:mandatory>true</mig:mandatory>
                    <mig:section-structure>group1.section1.subSection1.finRow1.finCell1</mig:section-structure>
                </mig:field-type>
            </mig:field>
            <mig:field name="taChrgOffMsg.taChrgOffCrit.chargeOffType">
                <mig:field-type type="one">
                    <mig:group-name>cota</mig:group-name>
                    <mig:page-name>cotacrit</mig:page-name>
                    <mig:control-type>Radio Button</mig:control-type>
                    <mig:ui-field>chargeOffMode</mig:ui-field>
                    <mig:label>FLT0045</mig:label>
                    <mig:mandatory>Y</mig:mandatory>
                </mig:field-type>
                <mig:field-type type="two">
                    <mig:group-name>Rtacof</mig:group-name>
                    <mig:page-name>Rtacof_criteria_form</mig:page-name>
                    <mig:control-type>FinRadioButtonGroup</mig:control-type>
                    <mig:ui-field>chargeMode</mig:ui-field>
                    <mig:label>FLT003817</mig:label>
                    <mig:mandatory>false</mig:mandatory>
                    <mig:section-structure>group1.section1.subSection12.finRow2.finCell4</mig:section-structure>
                </mig:field-type>
            </mig:field>
          </mig:fields>
        <mig:fields existence="ux">
            <mig:field name="taChrgOffMsg.taChrgOffCrit.Acct.acctName">
                <mig:field-type type="two">
                    <mig:group-name>Rtacof</mig:group-name>
                    <mig:page-name>Rtacof_criteria_form</mig:page-name>
                    <mig:control-type>FinAccountId</mig:control-type>
                    <mig:ui-field>acctId$accountNameDesc</mig:ui-field>
                    <mig:label>FLT001251</mig:label>
                    <mig:mandatory>true</mig:mandatory>
                    <mig:section-structure>group1.section1.subSection1.finRow1.finCell1</mig:section-structure>
                </mig:field-type>
            </mig:field>
            <mig:field name="taChrgOffMsg.taChrgOffCrit.Acct.Acct_1.Acct_2.1.acctName_2.1">
                <mig:field-type type="two">
                    <mig:group-name>Rtacof</mig:group-name>
                    <mig:page-name>Rtacof_criteria_form</mig:page-name>
                    <mig:control-type>FinAccountId</mig:control-type>
                    <mig:ui-field>acctId$accountNameDesc_2.1</mig:ui-field>
                    <mig:label>FLT001251</mig:label>
                    <mig:mandatory>true</mig:mandatory>
                    <mig:section-structure>group1.section1.subSection1.finRow1.finCell1</mig:section-structure>
                </mig:field-type>
            </mig:field>
           </mig:fields>
    </mig:field-details>
</mig:menu-compare>

我希望EXCEL包含行 - fiedname(唯一),group-name,page-name等(合并group-name,page-name as&#39; ONE&#39;)和另一个group-name,page-名称等(将其合并为&#39; TWO&#39;)

1 个答案:

答案 0 :(得分:0)

我正在进行相同的研究,我遇到xsl-excel-engine by Pavel Ptacek - 我还没有尝试过,但看起来很有希望。