下面是xml.Above,这是我试图从第一个出现的DayList节点中选择第一个ReportDate属性并将其分配给$ reportDate的代码。不幸的是,我无法让它工作。有任何想法吗?
<xsl:variable name ="reportDate">
<xsl:apply-templates select="ReportGroup/LOB"></xsl:apply-templates>
</xsl:variable>
<xsl:template match="ReportGroup/LOB">
<xsl:value-of select="List/DayList[@ReportDate][1]" />
</xsl:template>`enter code here`
<ReportGroup ReportName="UIP Coll Bankcard CAU" ReportNameMasterID="3622">
<LOB LOBMasterID="8613" GroupName="Bankcard UPP Completer Callbacks">
<List ListName="[ALM4] MQYC_UPP_BP_CP_A4">
<MtdList ReportDate="02/05/2015" DateType="MTD" Multipass="13" />
</List>
<List ListName="[ALM4] MQYC_UPP_BP_ONLY_A4">
<MtdList ReportDate="02/05/2015" DateType="MTD" Multipass="14" />
</List>
</LOB>
<LOB LOBMasterID="8612" GroupName="Bankcards CompleterPre-Del">
<List ListName="[ALM4] MQYC_UPP_HP_BP_A4">
<MtdList ReportDate="02/05/2015" DateType="MTD" Multipass="27" />
</List>
<List ListName="[ALM4] MQYC_UPP_HP_BP_CP_A4">
<MtdList ReportDate="02/05/2015" DateType="MTD" Multipass="1" />
</List>
<List ListName="[ALM4] MQYC_UPP_HP_CP_A4">
<MtdList ReportDate="02/05/2015" DateType="MTD" Multipass="18" />
</List>
<List ListName="[ALM4] MQYC_UPP_HP_ONLY_A4">
<MtdList ReportDate="02/05/2015" DateType="MTD" Multipass="52" />
</List>
<List ListName="[ALM4] MQYC_UPP_Verified_CP_ONLY_A4">
<MtdList ReportDate="02/05/2015" DateType="MTD" Multipass="67" />
</List>
</LOB>
<LOB LOBMasterID="8617" GroupName="Best Buy CAU">
<List ListName="[ALM2] MP7C_PXPZ_BP_CP_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="1" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="13" />
</List>
<List ListName="[ALM2] MP7C_PXPZ_BP_ONLY_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="1" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="1" />
</List>
<List ListName="[ALM2] MP7C_PXPZ_HP_BP_A2">
<MtdList ReportDate="02/02/2015" DateType="MTD" Multipass="1" />
</List>
<List ListName="[ALM2] MP7C_PXPZ_HP_BP_CP_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="0" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="0" />
</List>
<List ListName="[ALM2] MP7C_PXPZ_HP_CP_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="1" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="30" />
</List>
<List ListName="[ALM2] MP7C_PXPZ_HP_ONLY_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="4" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="52" />
</List>
<List ListName="[ALM2] MP7C_PXPZ_Verified_CP_ONLY_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="11" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="59" />
</List>
</LOB>
<LOB LOBMasterID="8608" GroupName="Bucket 1-5 PX_PZ">
<List ListName="[ALM4] MPBC_PX_PZ_BP_CP_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="11" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="110" />
</List>
<List ListName="[ALM4] MPBC_PX_PZ_BP_ONLY_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="1" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="48" />
</List>
<List ListName="[ALM4] MPBC_PX_PZ_HP_BP_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="6" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="141" />
</List>
<List ListName="[ALM4] MPBC_PX_PZ_HP_BP_CP_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="5" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="44" />
</List>
<List ListName="[ALM4] MPBC_PX_PZ_HP_CP_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="12" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="131" />
</List>
<List ListName="[ALM4] MPBC_PX_PZ_HP_ONLY_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="29" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="440" />
</List>
<List ListName="[ALM4] MPBC_PX_PZ_Verified_CP_ONLY_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="8" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="136" />
</List>
</LOB>
<LOB LOBMasterID="8601" GroupName="Buckets 1-5 Manual">
<List ListName="[ALM4] MPBM_DU_BP_CP_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="2" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="16" />
</List>
<List ListName="[ALM4] MPBM_DU_BP_ONLY_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="2" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="16" />
</List>
<List ListName="[ALM4] MPBM_DU_HP_BP_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="5" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="38" />
</List>
<List ListName="[ALM4] MPBM_DU_HP_CP_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="5" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="32" />
</List>
<List ListName="[ALM4] MPBM_DU_HP_ONLY_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="13" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="114" />
</List>
<List ListName="[ALM4] MPBM_DU_Verified_CP_ONLY_A4">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="18" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="126" />
</List>
</LOB>
<LOB LOBMasterID="8680" GroupName="Sears CAU">
<List ListName="[ALM2] MPSC_PXPZ_BP_CP_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="2" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="8" />
</List>
<List ListName="[ALM2] MPSC_PXPZ_BP_ONLY_A2">
<MtdList ReportDate="02/05/2015" DateType="MTD" Multipass="1" />
</List>
<List ListName="[ALM2] MPSC_PXPZ_HP_BP_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="2" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="16" />
</List>
<List ListName="[ALM2] MPSC_PXPZ_HP_BP_CP_A2">
<MtdList ReportDate="02/07/2015" DateType="MTD" Multipass="2" />
</List>
<List ListName="[ALM2] MPSC_PXPZ_HP_CP_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="15" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="131" />
</List>
<List ListName="[ALM2] MPSC_PXPZ_HP_ONLY_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="42" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="431" />
</List>
<List ListName="[ALM2] MPSC_PXPZ_Verified_CP_ONLY_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="18" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="154" />
</List>
<List ListName="[ALM2] MPSM_DU_HP_ONLY_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="2" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="18" />
</List>
<List ListName="[ALM2] MPSM_DU_Verified_CP_ONLY_A2">
<DayList ReportDate="02/08/2015" DateType="Day" Multipass="2" />
<MtdList ReportDate="02/08/2015" DateType="MTD" Multipass="10" />
</List>
</LOB>
</ReportGroup>
enter code here
答案 0 :(得分:0)
我认为您只想使用<xsl:variable name="reportDate" select="(ReportGroup/LOB/List/DayList/@ReportDate)[1]"/>
,因为它会找到第一个ReportDate
属性。