以下是具有以下内容的示例文件: 在xslt
中使用position()时,我们需要在xslt转换中提供一些帮助 <ElementOne>
<RecordA>AAA</RecordA>
</ElementOne>
<ElementOne>
<RecordA>BBB</RecordA>
</ElementOne>
<ElementOne>
<RecordA>CCC</RecordA>
</ElementOne>
<ElementTwo>
<DfiAccttNumber>123</DfiAccttNumber>
</ElementTwo>
<ElementTwo>
<DfiAccttNumber>9999</DfiAccttNumber>
</ElementTwo>
<ElementTwo>
<DfiAccttNumber>8889</DfiAccttNumber>
</ElementTwo>
<ElementTwo>
<DfiAccttNumber>0000</DfiAccttNumber>
</ElementTwo>
<ElementTwo>
<DfiAccttNumber>9696</DfiAccttNumber>
</ElementTwo>
<xsd:element name="HeaderElement">
<xsd:element name="ElementOne" nxsd:style="array" nxsd:cellSeparatedBy="${eol}" nxsd:conditionValue="1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RecordA" type="xsd:string" nxsd:style="fixedLength" nxsd:length="2" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ElementTwo" nxsd:style="array" nxsd:cellSeparatedBy="${eol}" nxsd:conditionValue="6">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RecordB" type="xsd:string" nxsd:style="fixedLength" nxsd:length="17" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:element>
<xsl:template match="/">
<xsl:variable name="cur"/>
<ebo:CreateReturnedItemListEBM>
<DataArea>
<xsl:for-each select="/imp1:HeaderElement/imp1:ElementTwo">
<xsl:variable name="cur" select="position()"/>
<ebo:CreateReturnedItemList>
<ebo:BankDetail>
<ebo:AccountNumber>
<ebo:Old>
<xsl:value-of select="/imp1:HeaderElement/imp1:ElementTwo[$cur]/imp1:RecordB"/>
</ebo:Old>
</ebo:AccountNumber>
</ebo:BankDetail>
<ebo:Payment>
<ebo:Bate>
<xsl:value-of select="../imp1:ElementOne[$cur]/imp1:RecordA"/>
</ebo:Bate>
</ebo:Payment>
</ebo:CreateReturnedItemList>
</xsl:for-each>
</DataArea>
</ebo:CreateReturnedItemListEBM>
<ebo:CreateReturnedItemList>
<ebo:BankDetail>
<ebo:AccountNumber>
<ebo:Old>123</ebo:Old>
</ebo:AccountNumber>
</ebo:BankDetail>
<ebo:Payment>
<ebo:Bate>AAA</ebo:Bate>
</ebo:Payment>
</ebo:CreateReturnedItemList>
<ebo:CreateReturnedItemList>
<ebo:BankDetail>
<ebo:AccountNumber>
<ebo:Old>9999</ebo:Old>
</ebo:AccountNumber>
</ebo:BankDetail>
<ebo:Payment>
<ebo:Bate>BBB</ebo:Bate>
</ebo:Payment>
</ebo:CreateReturnedItemList>
<ebo:CreateReturnedItemList>
<ebo:BankDetail>
<ebo:AccountNumber>
<ebo:Old>8889</ebo:Old>
</ebo:AccountNumber>
</ebo:BankDetail>
<ebo:Payment>
<ebo:Bate>CCC</ebo:Bate>
</ebo:Payment>
</ebo:CreateReturnedItemList>
<ebo:CreateReturnedItemList>
<ebo:BankDetail>
<ebo:AccountNumber>
<ebo:Old>0000</ebo:Old>
</ebo:AccountNumber>
</ebo:BankDetail>
<ebo:Payment>
<ebo:Bate/>
</ebo:Payment>
</ebo:CreateReturnedItemList>
<ebo:CreateReturnedItemList>
<ebo:BankDetail>
<ebo:AccountNumber>
<ebo:Old>9696</ebo:Old>
</ebo:AccountNumber>
</ebo:BankDetail>
<ebo:Payment>
<ebo:Bate/>
</ebo:Payment>
</ebo:CreateReturnedItemList>
由于cusor结束,Bate变空了。我需要应用&#39; RecordA&#39;的最后一个值。对这个贝特。如果可能,使用模板