所以我必须做一个报告,它将显示和统计基于CwaChannel和CwaOrderType的CwaProductCode。
继承我的xml:
<OrderEntry-Orders>
<CwaChannel>Customer Portal</CwaChannel>
<CwaOrderType>UT Sales</CwaOrderType>
<ListOfOrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>001</CwaProductCode>
</OrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>005</CwaProductCode>
</OrderEntry-LineItems>
</ListOfOrderEntry-LineItems>
</OrderEntry-Orders>
<OrderEntry-Orders>
<CwaChannel>Customer Portal</CwaChannel>
<CwaOrderType>UT Sales</CwaOrderType>
<ListOfOrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>005</CwaProductCode>
</OrderEntry-LineItems>
</ListOfOrderEntry-LineItems>
</OrderEntry-Orders>
<OrderEntry-Orders>
<CwaChannel>Customer Portal</CwaChannel>
<CwaOrderType>UT Redemption</CwaOrderType>
<ListOfOrderEntry-LineItems>
<OrderEntry-LineItems>
<CwaLineTotalAmount2>1000</CwaLineTotalAmount2>
<CwaProductCode>005</CwaProductCode>
</OrderEntry-LineItems>
</ListOfOrderEntry-LineItems>
</OrderEntry-Orders>
继承我的BIP代码:
<?for-each-group: OrderEntry-LineItems; CwaProductCode?>
<?if:../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal'?>
<?for-each: current-group()?>
<?CwaProductCode?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', xdoxslt:get_variable($_XDOCTX, 'countFund')+1)?>
<?xdoxslt:set_variable($_XDOCTX, 'TotalCount', xdoxslt:get_variable($_XDOCTX, 'TotalCount')+1)?>
<?xdoxslt:get_variable($_XDOCTX, 'countFund')?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', 0)?>
<?end if?>
<?end for-each-group?>
<?xdoxslt:get_variable($_XDOCTX, 'TotalCount')?>
但结果却好像没有条件。 例如,CwaProductCode将显示正确的结果,但它将完全计算所有内容,就像根本没有过滤一样。
不确定哪里出错。
答案 0 :(得分:0)
进行分组后,访问该分组上方的任何父级都会返回不明确的数据。它可能总是指向第一个OrderEntry-Orders&#39;节点。如果更改xml中元素的顺序,则可以看到这一点。
如果您的要求是仅将那些&#39; OrderEntry-LineItems&#39;具有CwaOrderType =&#39; UT Sales&#39;的节点和.CwaChannel =&#39;客户门户&#39;,你可以在这样的分组中直接给出过滤器:
<?for-each-group: OrderEntry-LineItems[../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal']; CwaProductCode?>
试试这段代码:
<?for-each-group: OrderEntry-LineItems[../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal']; CwaProductCode?>
<?for-each: current-group()?>
<?CwaProductCode?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', xdoxslt:get_variable($_XDOCTX, 'countFund')+1)?>
<?xdoxslt:set_variable($_XDOCTX, 'TotalCount', xdoxslt:get_variable($_XDOCTX, 'TotalCount')+1)?>
<?xdoxslt:get_variable($_XDOCTX, 'countFund')?>
<?xdoxslt:set_variable($_XDOCTX, 'countFund', 0)?>
<?end for-each-group?>
<?xdoxslt:get_variable($_XDOCTX, 'TotalCount')?>
给出了这个结果:
001
1
1
005
1
005
1
3
<?for-each-group: OrderEntry-LineItems[../../CwaOrderType='UT Sales' and ../../CwaChannel='Customer Portal']; CwaProductCode?>
<?CwaProductCode?>
<?count(current-group()/.)?>
<?xdoxslt:set_variable($_XDOCTX, 'TotalCount', xdoxslt:get_variable($_XDOCTX, 'TotalCount')+ count(current-group()/.))?>
<?end for-each-group?>
<?xdoxslt:get_variable($_XDOCTX, 'TotalCount')?>
给出
001
1
005
2
3