我是XSLT的新手,我在计算表中的小节总计时遇到了问题。我正在使用XSLT 1.0。我能够从XML中获得Grand Total,但是获取子部分有很多ifs/else和很难解释的条件。 请在下面找到示例表和XML。在表中计算小节总计
所以我想要做的是将文档1与文档2进行比较。 如果Recno匹配这两个文档,那么这些记录将进入“相同”。 如果一个Rec在Document1中而不在Document2中,那么它将进入“Add”部分。 如果一个Rec在Document2中,而不在Document1中,那么它将进入“删除”部分。
我试着到处搜索,但到目前为止没有运气。任何指针赞赏
我的输出HTML表应该是这样的:
----------------------------------------------------------------
Section RecNo Desc Qty Value
----------------------------------------------------------------
Same 111 Desc1 1 $100.00
Same 444 Desc1 1 $200.00
Same 123 Desc1 1 $300.00
---------------------------------------------------------------
Same Total $600.00
---------------------------------------------------------------
Add 555 Desc1 1 $100.00
Add 999 Desc1 1 $100.00
---------------------------------------------------------------
Add Total $200.00
---------------------------------------------------------------
Delete 777 Desc1 1 $200.00
Delete 888 Desc1 1 $200.00
---------------------------------------------------------------
Delete Total $400.00
---------------------------------------------------------------
Grand Total $1200.00
这里是我的XML
<?xml version="1.0" encoding="utf-8"?>
<Logia xmlns="com.configsc">
<DocHeader xmlns="com.configsc.docheader">
<Document>
<Downto>
<rec_no>111</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$200.00</Value>
</Downto>
<Downto>
<rec_no>333</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$200.00</Value>
</Downto>
<Downto>
<rec_no>444</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$200.00</Value>
</Downto>
<Downto>
<rec_no>555</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$200.00</Value>
</Downto>
<Downto>
<rec_no>123</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$300.00</Value>
</Downto>
</Document>
<Document>
<Downto>
<rec_no>222</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$200.00</Value>
</Downto>
<Downto>
<rec_no>111</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$200.00</Value>
</Downto>
<Downto>
<rec_no>444</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$200.00</Value>
</Downto>
<Downto>
<rec_no>777</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$200.00</Value>
</Downto>
<Downto>
<rec_no>888</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$200.00</Value>
</Downto>
<Downto>
<rec_no>111</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$200.00</Value>
</Downto>
<Downto>
<rec_no>123</rec_no>
<desc>Desc1</desc>
<qty>1</qty>
<Value>$300.00</Value>
</Downto>
</Document>
</Material>
</DocHeader>
</Logia>
你绝对应该发布你的输入XML;你可能应该发布你想要的输出XML和你迄今为止尝试过的。谢谢。 – kjhughes 2014-10-08 15:30:08
感谢您的意见。同时这个xml对于5K的行很大,并且和我的xslt文件一样,它有一些1K的代码。编辑这些以使通用可能会很耗时 – user2822294 2014-10-08 15:51:15
请将您输入**的最小但完整的示例作为代码**发布。如果数据是正确的 - 上面表格的内容可以做得很好 - 我认为目前不是这样,因为分组没有意义。还要解释 - 或者最好是显示 - 输出的预期格式。 – 2014-10-08 15:56:03