提问人:Matthew Fry 提问时间:9/26/2023 最后编辑:Yitzhak KhabinskyMatthew Fry 更新时间:9/26/2023 访问量:48
XSLT 数学帮助 - “XSL:value-of select”语句内部
XSLT Math Help - Inside of 'XSL:value-of select' Statement
问:
我无法让数学在我的 XSLT 中工作。下面是代码片段:
$<xsl:value-of select="(((sum(LOOPSAC[SAC/SAC01='C']/SAC/SAC05)-sum(LOOPSAC[SAC/SAC01='A']/SAC/SAC05)) div 100) +sum(LOOPIT1/TXI/TXI02))"/>
我需要将所有 SAC05 值相加,当 SAC01 = A 时减去 SAC05 值,然后将这个总数除以 100。然后,我需要添加 TXI02 值(这些值不需要除以 100)。
由于某种原因,上述代码未将 TXI02 值包含在总数中。它计算第一部分就好了。
谢谢! 马 特
下面是一个示例 XML 文件,显示了我正在使用的内容。上面的代码是用于计算“小计”字段的代码。
<?xml version="1.0"?>
<Document810>
<HEADER>
<ST>
<Version>4010</Version>
<Interchange FunctionalIdentifier="IN" InterchangeDate="230907" ReceiverID="TEST" SenderID="TEST"> </Interchange>
<ST01>810</ST01>
<ST02>0012</ST02>
</ST>
<BIG>
<BIG01>20230906</BIG01>
<BIG02>123456</BIG02>
<BIG03> </BIG03>
<BIG04> </BIG04>
<BIG05> </BIG05>
<BIG06> </BIG06>
<BIG07>PR</BIG07>
<BIG08>00</BIG08>
</BIG>
<REF>
<REF01>12</REF01>
<REF02>123456</REF02>
<REF03>BILLING ACCOUNT NUMBER</REF03>
</REF>
<LOOPN1>
<N1>
<N101>RE</N101>
<N102>TEST ENERGY</N102>
<N103>1</N103>
<N104>006915953</N104>
<N105> </N105>
<N106>41</N106>
</N1>
<N3>
<N301>ADDRESS FIELD</N301>
</N3>
<N4>
<N401>MINNEAPOLIS</N401>
<N402>MN</N402>
<N403>554849477</N403>
</N4>
<PER>
<PER01>IC</PER01>
<PER02> </PER02>
<PER03>TE</PER03>
<PER04>8004814700</PER04>
</PER>
</LOOPN1>
<LOOPN1>
<N1>
<N101>BT</N101>
<N102>TEST ADDRESS</N102>
<N103>ZZ</N103>
<N104>TEST</N104>
<N105> </N105>
<N106>40</N106>
</N1>
<N3>
<N301>123456 MAIN ST</N301>
</N3>
<N4>
<N401>DENVER</N401>
<N402>CO</N402>
<N403>802042305</N403>
</N4>
<PER>
<PER01>IC</PER01>
<PER02>JOE SMITH</PER02>
<PER03>TE</PER03>
<PER04>3037579567</PER04>
</PER>
<ITD>
<ITD01> </ITD01>
<ITD02> </ITD02>
<ITD03> </ITD03>
<ITD04> </ITD04>
<ITD05> </ITD05>
<ITD06>20230926</ITD06>
</ITD>
<BAL>
<BAL01>P</BAL01>
<BAL02>PB</BAL02>
<BAL03>64.87</BAL03>
</BAL>
<BAL>
<BAL01>P</BAL01>
<BAL02>TP</BAL02>
<BAL03>64.87</BAL03>
</BAL>
<BAL>
<BAL01>M</BAL01>
<BAL02>J9</BAL02>
<BAL03>0</BAL03>
</BAL>
<BAL>
<BAL01>M</BAL01>
<BAL02>PB</BAL02>
<BAL03>78.66</BAL03>
</BAL>
<BAL>
<BAL01>M</BAL01>
<BAL02>YB</BAL02>
<BAL03>78.66</BAL03>
</BAL>
</LOOPN1>
</HEADER>
<DETAIL>
<LOOPIT1>
<IT1>
<IT101>000001</IT101>
<IT102> </IT102>
<IT103> </IT103>
<IT104> </IT104>
<IT105> </IT105>
<IT106>SV</IT106>
<IT107>ELECTRIC</IT107>
<IT108>C3</IT108>
<IT109>METER</IT109>
</IT1>
<TXI>
<TXI01>OH</TXI01>
<TXI02>0.75</TXI02>
<TXI03> </TXI03>
<TXI04> </TXI04>
<TXI05> </TXI05>
<TXI06> </TXI06>
<TXI07> </TXI07>
<TXI08> </TXI08>
<TXI09> </TXI09>
<TXI10>Energy Assistance Ch</TXI10>
</TXI>
<MEA>
<MEA01>AA</MEA01>
<MEA02>MU</MEA02>
<MEA03>1</MEA03>
<MEA04>KH</MEA04>
<MEA05>39566</MEA05>
<MEA06>40029</MEA06>
<MEA07>51</MEA07>
</MEA>
<LOOPPID>
<PID>
<PID01>F</PID01>
<PID02> </PID02>
<PID03> </PID03>
<PID04> </PID04>
<PID05>ENERGY SERVICE</PID05>
</PID>
<REF>
<REF01>LU</REF01>
<REF02>304604770</REF02>
<REF03>PREMISE ACCOUNT NUMBER</REF03>
</REF>
<REF>
<REF01>MG</REF01>
<REF02>000081951065</REF02>
<REF03>METER NUMBER</REF03>
</REF>
<REF>
<REF01>NH</REF01>
<REF02>C</REF02>
<REF03>COMMERCIAL SERVICE</REF03>
</REF>
<DTM>
<DTM01>150</DTM01>
<DTM02>20230804</DTM02>
</DTM>
<DTM>
<DTM01>151</DTM01>
<DTM02>20230905</DTM02>
</DTM>
</LOOPPID>
<LOOPSLN>
<SLN>
<SLN01>000001</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>N</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ENC001</SAC04>
<SAC05> </SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08> </SAC08>
<SAC09>KH</SAC09>
<SAC10>463</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>TOTAL ENERGY</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000002</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ENC001</SAC04>
<SAC05>4098</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.08852</SAC08>
<SAC09>KH</SAC09>
<SAC10>463</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>COMMERCIAL SERVICE</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000003</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>FFR001</SAC04>
<SAC05>1168</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>5.84</SAC08>
<SAC09>EA</SAC09>
<SAC10>2</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>SERVICE AND FACILITY</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000004</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ADJ002</SAC04>
<SAC05>40</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.00086</SAC08>
<SAC09>KH</SAC09>
<SAC10>463</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>TRANS COST ADJ</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000005</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ADJ002</SAC04>
<SAC05>1369</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.02956</SAC08>
<SAC09>KH</SAC09>
<SAC10>463</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>ELEC COMMODITY ADJ</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000006</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ADJ002</SAC04>
<SAC05>86</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.00186</SAC08>
<SAC09>KH</SAC09>
<SAC10>463</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>DEMAND SIDE MGMT COST</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000007</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ADJ002</SAC04>
<SAC05>188</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.00406</SAC08>
<SAC09>KH</SAC09>
<SAC10>463</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>PURCH CAP COST ADJ</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000008</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>FFR001</SAC04>
<SAC05>73</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.009818</SAC08>
<SAC09>EA</SAC09>
<SAC10>74.35</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>RENEW. ENERGY STD ADJ</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000009</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ADJ002</SAC04>
<SAC05>73</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.009818</SAC08>
<SAC09>KH</SAC09>
<SAC10>74.35</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>COLO ENERGY PLAN ADJ</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000010</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ADJ002</SAC04>
<SAC05>542</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.0117</SAC08>
<SAC09>KH</SAC09>
<SAC10>463</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>GRSA E</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000011</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ADJ002</SAC04>
<SAC05>5</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.0001</SAC08>
<SAC09>KH</SAC09>
<SAC10>463</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>TRANS ELEC PLAN</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000012</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ADJ002</SAC04>
<SAC05>61</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.00131</SAC08>
<SAC09>KH</SAC09>
<SAC10>463</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>RDA</SAC15>
</SAC>
</LOOPSAC>
<LOOPSLN>
<SLN>
<SLN01>000013</SLN01>
<SLN02> </SLN02>
<SLN03>A</SLN03>
</SLN>
</LOOPSLN>
<LOOPSAC>
<SAC>
<SAC01>C</SAC01>
<SAC02> </SAC02>
<SAC03>EU</SAC03>
<SAC04>ADJ002</SAC04>
<SAC05>210</SAC05>
<SAC06> </SAC06>
<SAC07> </SAC07>
<SAC08>0.00453</SAC08>
<SAC09>KH</SAC09>
<SAC10>463</SAC10>
<SAC11> </SAC11>
<SAC12> </SAC12>
<SAC13> </SAC13>
<SAC14> </SAC14>
<SAC15>EGCRR</SAC15>
</SAC>
</LOOPSAC>
<LOOPN1>
<N1>
<N101>MQ</N101>
<N102>CDOT R1430010</N102>
</N1>
<N3>
<N301>6019 W 52ND AVE</N301>
</N3>
<N4>
<N401>ARVADA</N401>
<N402>CO</N402>
<N403>80002</N403>
</N4>
</LOOPN1>
</LOOPIT1>
</DETAIL>
<SUMMARY>
<TDS>
<TDS01>7866</TDS01>
</TDS>
<CTT>
<CTT01>1</CTT01>
</CTT>
<SE>
<SE01>58</SE01>
<SE02>0012</SE02>
</SE>
</SUMMARY>
</Document810>
答:
0赞
michael.hor257k
9/26/2023
#1
AFAICT,是 的子项。LOOPSAC
LOOPIT1
您没有显示计算的上下文,但如果表达式:
sum(LOOPSAC[SAC/SAC01='C']/SAC/SAC05)
有效,那么你必须在 的上下文中。LOOPIT1
现在,也是孩子。因此,如果您已经在 的上下文中,则表达式:TX1
LOOPIT1
LOOPIT1
sum(LOOPIT1/TXI/TXI02)
将返回 0,因为它不是其本身的子节点,并且此路径没有选择任何节点。它需要是:LOOPIT1
sum(TXI/TXI02)
如果你从隔离表达式开始,你可以自己推断出这一切:
count(LOOPIT1/TXI/TXI02)
并从那里继续。
评论