0
如果有2個節點,請您幫我減去內部文本。產生如何在XSLT中減去兩個節點的內部文本
我的XML是:(原始XML是直到OriIndex)
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Test>
<TestPhase>1</TestPhase>
<TestFlow>1</TestFlow>
<TestParameter>1</TestParameter>
<OriIndex>0</OriIndex>
<SortedIndex>0</SortedIndex>
<Diff>NaN</Diff>
</Test>
.
.
.
.
.
我不能夠得到DIFF。例如它應該是<SortedIndex>10</SortedIndex> - <OriIndex>5</OriIndex> Equals
5。
我的XSLT是:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding = "UTF-8" indent="yes" omit-xml-declaration="no" standalone="yes" />
<xsl:template match="Root">
<xsl:copy>
<xsl:apply-templates select="Test">
<xsl:sort select="TestPhase" data-type="number" order="ascending"/>
<xsl:sort select="TestFlow" data-type="number" order="ascending"/>
<xsl:sort select="TestParameter" data-type="number" order="ascending"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Test">
<xsl:copy>
<xsl:apply-templates select="@* | *"/>
<SortedIndex><xsl:value-of select="position() - 1"/></SortedIndex>
<Diff><xsl:value-of select="@SortedIndex - @OriIndex" /></Diff>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
請幫助。非常感謝您的努力。
非常感謝。
乾杯, newbuntu
非常感謝Martin Honnen。它工作正常。我其實已經錯過了一個邏輯。你能請教我如何編寫代碼。我想要了解當前OriIndex內部文本和以前的OriIndex內部文本(僅在此之前的文本)之間的區別。我把: ,但它有編譯錯誤。請幫忙。乾杯:) –
newbuntu