消除xsl导出Crystal报表到XML的重复值

时间:2015-02-18 22:27:03

标签: xml xslt crystal-reports

我有一个水晶报告,它创建了以下用于导入的XML。 (xml编码新手)

<Text Name="Text8"><TextValue>ORI</TextValue>
</Text>
<Field Name="BBPCTITEM1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[0BBP_CTITEM]}"><FormattedValue>10</FormattedValue><Value>10</Value></Field>
<Field Name="Measures00O2TFHPXGNUD31J0EUMEK7NMValue1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[Measures]-[00O2TFHPXGNUD31J0EUMEK7NM]-Value}"><FormattedValue>50,000.00</FormattedValue><Value>50000.00</Value></Field>
<Field Name="ZCFCONTR8ZCFCONTR1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[ZCF_CONTR]-[8ZCF_CONTR]}"><FormattedValue>40000715</FormattedValue><Value>40000715</Value></Field>
<Field Name="ZCFCONTRZCFCOSTDT2ZCFCONTRZCFCOSTDT1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[ZCF_CONTR__ZCFCOSTDT]-[2ZCF_CONTR__ZCFCOSTDT]}"><FormattedValue>01/01/2013</FormattedValue><Value>01/01/2013</Value></Field>
<Field Name="GTBSTKD1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[0GT_BSTKD]}"><FormattedValue>#</FormattedValue><Value>#</Value></Field>
<Field Name="PLANT20PLANT1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[0PLANT]-[20PLANT]}"><FormattedValue>5000</FormattedValue><Value>5000</Value></Field>
<Field Name="SOLDTO20SOLDTO1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[0SOLD_TO]-[20SOLD_TO]}"><FormattedValue>EX0003</FormattedValue><Value>EX0003</Value></Field>
<Field Name="Measures00O2TFHPXGNUD31J0EUMEK7NMUnit1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[Measures]-[00O2TFHPXGNUD31J0EUMEK7NM]-Unit}"><FormattedValue>TON</FormattedValue><Value>TON</Value></Field>
<Field Name="MATERIAL20MATERIAL1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[0MATERIAL]-[20MATERIAL]}"><FormattedValue>20001</FormattedValue><Value>20001</Value></Field>
<Field Name="SHIPTYPE10SHIPTYPE1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[0SHIP_TYPE]-[10SHIP_TYPE]}"><FormattedValue>Vessel</FormattedValue><Value>Vessel</Value></Field>
<Field Name="INCOTERMS20INCOTERMS1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[0INCOTERMS]-[20INCOTERMS]}"><FormattedValue>DEL</FormattedValue><Value>DEL</Value></Field>
<Field Name="SHIPTO20SHIPTO1" FieldName="{ZCFSDMC03_ZOTC_ZCFSDMC03_Q006.[0SHIP_TO]-[20SHIP_TO]}"><FormattedValue>206516</FormattedValue><Value>206516</Value></Field>
</Section>
</Details>

格式返回Formated Value和Value。如何创建xsl模板以仅为每个详细信息字段返回一个值?

我试过这个:

<xsl:template match="Details" >





    <xsl:for-each select="Details">
                <xsl:value-of select="Section/Field[@Name='ZCFCONTR8ZCFCONTR1']"/>
                <xsl:value-of select="Section/Field[@Name='BBPCTITEM1']"/>
                <xsl:value-of select="Section/Field[@Name='Measures00O2TFHPXGNUD31J0EUMEK7NM']"/>
                <xsl:value-of select="Section/Field[@Name='Measures00O2TFHPXGNUD31J0EUMEK7NMUnit1']"/>
                <xsl:value-of select="Section/Field[@Name='GTBSTKD1']"/>
                <xsl:value-of select="Section/Field[@Name='ZCFCONTRZCFCOSTDT1']"/>
                <xsl:value-of select="Section/Field[@Name='SOLDTO20SOLDTO1']"/>
                <xsl:value-of select="Section/Field[@Name='MATERIAL20MATERIAL1']"/>
                <xsl:value-of select="Section/Field[@Name='SHIPTYPE1']"/>
                <xsl:value-of select="Section/Field[@Name='INCOTERMS1']"/>
                <xsl:value-of select="Section/Field[@Name='PLANT20PLANT1']"/>
                <xsl:value-of select="Section/Field[@Name='SHIPTO20SHIPTO1']"/>


            </xsl:for-each>





</xsl:template>

但得到相同的结果。

提前感谢您的帮助。

Joe Wiorek

1 个答案:

答案 0 :(得分:0)

尝试更改:

<xsl:value-of select="Section/Field[@Name='ZCFCONTR8ZCFCONTR1']"/>

为:

<xsl:value-of select="Section/Field[@Name='ZCFCONTR8ZCFCONTR1']/Value"/>