0
我們在xpath 1.0和XalanJ 2.7.1中使用xslt 1.0。 我們對我們的模板進行分析並嘗試縮短通話時間。所以出最大的熱點是:使用XSLT 1.0進行xslt模板處理期間的優化?
<xsl:template name="tplAttribute">
<xsl:param name="sourceObject" />
<xsl:param name="sourceName" />
<xsl:param name="targetName" />
<xsl:variable name="sourceAttribute" select="$sourceObject/attribute[@name = $sourceName]" />
<xsl:if test="$sourceAttribute">
<dcx:attribute name="{$targetName}">
<xsl:value-of select="$sourceAttribute" />
</attribute>
</xsl:if>
</xsl:template>
871次點擊的平均時間是103和變量59ms。
是否有爲了減少改造的任何時間更好的解決方案?
編輯: 輸入結構模板調用時的過程 'sourceObject':
object
tplAttribute
tplAttribute
tplAttributeDefault
tplAttribute
tplAttributeSomeDifferentLogic
tplAttribute
tplAttributeOther
有多少「屬性」元素通常會作爲$ sourceObject的子元素被找到? –
取決於從20到100.所以我們有$ sourceObject,並且在其中我們必須在其中找到一個特定的屬性。但是,我們必須尋找另一個,等等。在某些情況下,我們有不同的邏輯 - tplAttributeOther等。所以我不確定變量的創建是否會減慢進程,或者如果我們有兩個選擇而不是sourceAttribute,基於處理器優化,var會更快嗎? – Xelian
我不知道Xalan的內部。 Saxon-EE可能會創建一個索引來評估這一個 - 試一試,讓我們知道結果。 –