我希望根据标题值在InvoiceLine上创建TaxTotal。然后,我希望将行值(LIT_VatExcludedAmount)映射到正确的行(在TaxableAmount中)。
我只能使它工作以将第一行的值映射到目标中的每一行。或者在每一行上具有源的所有值。因此,对于3行,每行3个结果。
来源:
string Version = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion", "ProductName", null);
XSLT代码:
SELECT * FROM disease_symptoms
JOIN disease ON disease_symptoms.disease_id = disease.id
WHERE disease_symptoms.symptoms_id IN (14, 15)
ORDER BY `disease`.`probability` DESC
我期望如下所示,其中每一行都有正确的TaxableAmount。 我已经尝试过select =“ Field [@ Type ='LIT_VatExcludedAmount']”,但后来我只得到一个空标记。
<Documents>
<Document>
<Invoice>
<Fields>
<Field Type="BTWverlegd" TextDetail="AE">Ja</Field>
</Fields>
<Tables>
<Table>
<TableRow>
<Field Name="Li_Omschrijving" Type="LIT_ArticleName" PageNumber="1" Position="223,1528,377,1560">Artikel 1</Field>
<Field Name="Li_Aantal" Type="LIT_DeliveredQuantity" PageNumber="1" Position="1509,1530,1585,1566">3.00</Field>
<Field Name="Li_EenheidsPrijs" Type="LIT_UnitPriceAmount" PageNumber="1" Position="1832,1530,1908,1566">2.25</Field>
<Field Name="Li_NettoBedrag" Type="LIT_VatExcludedAmount" PageNumber="1" Position="2154,1530,2230,1566">6.75</Field>
</TableRow>
<TableRow>
<Field Name="Li_Omschrijving" Type="LIT_ArticleName" PageNumber="1" Position="223,1589,377,1621">Artikel 2</Field>
<Field Name="Li_Aantal" Type="LIT_DeliveredQuantity" PageNumber="1" Position="1509,1591,1585,1627">5.00</Field>
<Field Name="Li_EenheidsPrijs" Type="LIT_UnitPriceAmount" PageNumber="1" Position="1809,1591,1909,1627">28.00</Field>
<Field Name="Li_NettoBedrag" Type="LIT_VatExcludedAmount" PageNumber="1" Position="2109,1591,2229,1627">140.00</Field>
</TableRow>
<TableRow>
<Field Name="Li_Omschrijving" Type="LIT_ArticleName" PageNumber="1" Position="223,1649,376,1681">Artikel 3</Field>
<Field Name="Li_Aantal" Type="LIT_DeliveredQuantity" PageNumber="1" Position="1509,1651,1585,1687">7.00</Field>
<Field Name="Li_EenheidsPrijs" Type="LIT_UnitPriceAmount" PageNumber="1" Position="1810,1651,1910,1687">15.50</Field>
<Field Name="Li_NettoBedrag" Type="LIT_VatExcludedAmount" PageNumber="1" Position="2109,1651,2229,1687">108.50</Field>
</TableRow>
</Table>
</Tables>
</Invoice>
</Document>
</Documents>
答案 0 :(得分:0)
您可能想将内部xsl:for-each
更改为xsl:if
,否则您将自己定位在另一个节点上,而失去了原先放置的tableRow
<xsl:if test="../../../Fields/Field[@Type='BTWverlegd' and @TextDetail='AE']">
此外,在内部xsl:for-each
中,您有以下xsl:value-of
语句
<xsl:value-of select="/Documents/Document/....
通过以/
开头表达式,您将忽略当前选择的节点,而是搜索整个文档。
无论如何,您实际上根本不需要xsl:for-each
。就是这样...
<xsl:value-of select="Field[@Type='LIT_VatExcludedAmount']"/>
尝试使用此XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cac="cac"
xmlns:cbc="cbc"
version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:for-each select="Documents/Document/Invoice/Tables/Table/TableRow">
<cac:InvoiceLine>
<cbc:InvoicedQuantity>
<xsl:value-of select="Field[@Type='LIT_DeliveredQuantity']"/>
</cbc:InvoicedQuantity>
<xsl:if test="../../../Fields/Field[@Type='BTWverlegd' and @TextDetail='AE']">
<cac:TaxTotal>
<cac:TaxSubtotal>
<cbc:TaxableAmount>
<xsl:value-of select="Field[@Type='LIT_VatExcludedAmount']"/>
</cbc:TaxableAmount>
</cac:TaxSubtotal>
</cac:TaxTotal>
</xsl:if>
</cac:InvoiceLine>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>