我有以下xml:
<LzMessage>
<LzPostExecution>
<LzMarketExecution>
<LzExecutionDetail>
<LzExecutionId>LNE12345</LzExecutionId>
<LzPostingVersion>1</LzPostingVersion>
<LzInstrumentId>INSTRID</LzInstrumentId>
<LzInstrumentName>INSTR NAME</LzInstrumentName>
<LzSide>B</LzSide>
<LzTradeType>A</LzTradeType>
<LzSettlementCurrency>DKK</LzSettlementCurrency>
<LzCounterpartyId>PTY</LzCounterpartyId>
<LzSettlementDate>2015070900000000</LzSettlementDate>
<LzCommissionBasis>BP</LzCommissionBasis>
<LzCommissionRate>0</LzCommissionRate>
<LzCommissionAmount>0</LzCommissionAmount>
<LzCommissionType>H</LzCommissionType>
<LzTradeDate>2015070700000000</LzTradeDate>
<LzOrderOriginatorId/>
<LzPostedBy>BOB</LzPostedBy>
<LzExecutionQuantity>95000</LzExecutionQuantity>
<LzExecutionPrice>107.99</LzExecutionPrice>
<LzPriceType>CLEAN</LzPriceType>
<LzFxRate>1</LzFxRate>
<LzContractSize>0</LzContractSize>
<LzGrossConsideration>103665.43</LzGrossConsideration>
<LzAccruedInterest>1074.93</LzAccruedInterest>
<LzCouponRate>1.75</LzCouponRate>
<LzOrderId>LNO12345</LzOrderId>
<LzExchangeId/>
<LzPaydownFactor>1</LzPaydownFactor>
<LzCurrentFaceQuantity>95000</LzCurrentFaceQuantity>
<LzPriceYieldEntry>P</LzPriceYieldEntry>
<LzExecutionYield>0.9365</LzExecutionYield>
<LzExecutionDatetime>2015070714185800</LzExecutionDatetime>
<LzRate>0</LzRate>
<LzReferenceRate>0</LzReferenceRate>
<LzPoints>0</LzPoints>
<LzUserData1/>
<LzFarExecutionQuantity>0</LzFarExecutionQuantity>
<LzFarExecutionQuantity2>0</LzFarExecutionQuantity2>
<LzSide2/>
<LzExecutionQuantity2>0</LzExecutionQuantity2>
<LzInstrument2Id/>
<LzSettlementDate2/>
<LzOrderType>1</LzOrderType>
<LzInstrumentIsin>DK0009923138</LzInstrumentIsin>
<LzInstrumentSedol>BMTRT97</LzInstrumentSedol>
<LzDealingDesk>DESK</LzDealingDesk>
<LzTransactionId>1234567</LzTransactionId>
<LzExecutionCurrency>DKK</LzExecutionCurrency>
<LzReferenceYield>0</LzReferenceYield>
<LzSpread>0</LzSpread>
<LzReferencePrice>0</LzReferencePrice>
<LzReferenceInstrumentId/>
<LzReferenceInstrumentName/>
</LzExecutionDetail>
<LzOrderDetail>
<LzOrderId>LNO12346</LzOrderId>
<LzPostingVersion/>
<LzTraderInstruction/>
<LzListId/>
<LzUserData1/>
<LzUserData2/>
<LzSourceId>SOURCE</LzSourceId>
<LzMinervaInstrumentType>3</LzMinervaInstrumentType>
<LzUserData11/>
<LzCurrencyQuotation>DKK</LzCurrencyQuotation>
<LzCurrencyQuotation2/>
<LzAddedBy>blah</LzAddedBy>
<LzAddedDatetime>2015070714180594</LzAddedDatetime>
<LzApprovedDatetime>2015070714180594</LzApprovedDatetime>
<LzApproverId/>
<LzDealerNote/>
<LzDealingDesk>DESK</LzDealingDesk>
<LzDrivingQuantity>1</LzDrivingQuantity>
<LzManagerId>BOB</LzManagerId>
<LzOriginalQuantity>95000</LzOriginalQuantity>
<LzWorkingTraders/>
</LzOrderDetail>
</LzMarketExecution>
<LzClientExecution>
<LzExecutionDetail>
<LzExecutionId>LNE12346</LzExecutionId>
<LzPostingVersion>1</LzPostingVersion>
<LzAccountId>ACC1</LzAccountId>
<LzAccountName>Account 1</LzAccountName>
<LzExecutionQuantity>95000</LzExecutionQuantity>
<LzExecutionPrice>107.99</LzExecutionPrice>
<LzGrossConsideration>103665.43</LzGrossConsideration>
<LzAccruedInterest>1074.93</LzAccruedInterest>
<LzFxRate>1</LzFxRate>
<LzPaydownFactor>1</LzPaydownFactor>
<LzCurrentFaceQuantity>95000</LzCurrentFaceQuantity>
<LzCommissionBasis>BP</LzCommissionBasis>
<LzCommissionRate>0</LzCommissionRate>
<LzCommissionAmount>0</LzCommissionAmount>
<LzSideCode>BO</LzSideCode>
<LzGiveUpCommissionCounterpartyId>PTY</LzGiveUpCommissionCounterpartyId>
<LzExposure>0</LzExposure>
<LzRate>0</LzRate>
<LzReferenceRate>0</LzReferenceRate>
<LzPoints>0</LzPoints>
<LzFarExecutionQuantity>0</LzFarExecutionQuantity>
<LzFarExecutionQuantity2>0</LzFarExecutionQuantity2>
<LzSide2/>
<LzExecutionQuantity2>0</LzExecutionQuantity2>
<LzSettlementDate2/>
<LzSettlementDate>2015070900000000</LzSettlementDate>
<LzSide>B</LzSide>
<LzOrderType>1</LzOrderType>
<lzmarketaccountname>ACC</lzmarketaccountname>
</LzExecutionDetail>
<LzAccountAllocation>
<LzAllocationDetail>
<LzExecutionNote/>
</LzAllocationDetail>
</LzAccountAllocation>
</LzClientExecution>
</LzPostExecution>
以及以下xslt:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl acmex" xmlns:acmex="urn:schemas-acme-com:xslt-app-extensions">
<xsl:output method="xml" indent="yes"/>
<!--Copy whole message-->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*">
<xsl:with-param name="instrType" select="//LzMarketExecution/LzOrderDetail/LzMinervaInstrumentType"/>
<xsl:with-param name="clientAIValues">
<xsl:for-each select="//LzClientExecution/LzExecutionDetail">
<originalAI>
<xsl:value-of select="LzAccruedInterest"/>
</originalAI>
<tcAI>
<xsl:value-of select="acmex:DeriveValue('ClientTrade','AccruedInterest','',concat(LzExecutionId,'|',LzPostingVersion),'')"/>
</tcAI>
</xsl:for-each>
</xsl:with-param>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="//LzMarketExecution/LzExecutionDetail/LzAccruedInterest">
<xsl:param name="instrType"/>
<xsl:param name="clientAIValues"/>
<xsl:copy>
<xsl:choose>
<xsl:when test="$instrType='3'">
<xsl:value-of select="sum(msxsl:node-set($clientAIValues)/tcAI)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
<xsl:template match="//LzMarketExecution/LzExecutionDetail/LzGrossConsideration">
<xsl:param name="instrType"/>
<xsl:param name="clientAIValues"/>
<xsl:copy>
<xsl:choose>
<xsl:when test="$instrType='3'">
<xsl:value-of select=". - sum(msxsl:node-set($clientAIValues)/originalAI) + sum(msxsl:node-set($clientAIValues)/tcAI)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
<xsl:template match="//LzClientExecution/LzExecutionDetail/LzAccruedInterest">
<xsl:param name="instrType"/>
<xsl:copy>
<xsl:choose>
<xsl:when test="$instrType='3'">
<xsl:value-of select="acmex:DeriveValue('ClientTrade','AccruedInterest','',concat(../LzExecutionId,'|',../LzPostingVersion),'')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
<xsl:template match="//LzClientExecution/LzExecutionDetail/LzGrossConsideration">
<xsl:param name="instrType"/>
<xsl:copy>
<xsl:choose>
<xsl:when test="$instrType='3'">
<xsl:value-of select=". - ../LzAccruedInterest + acmex:DeriveValue('ClientTrade','AccruedInterest','',concat(../LzExecutionId,'|',../LzPostingVersion),'')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
当我应用这个xslt时,acmex:DeriveValue扩展方法被调用110次,而我希望它被调用3次。不确定为什么?
答案 0 :(得分:1)
好<xsl:template match="node()|@*">
匹配您没有任何更具体模板的节点。然后在该模板内部,将模板应用于所有属性和所有子节点,并计算调用扩展函数的参数值。也许你想使用一次计算值的全局参数或变量。