我很陌生XSL和XML,希望您能帮我解决一个简单的问题。我的XML文件中有两个数字数组需要加总。这是XML文件的一部分:
<?xml version="1.0" encoding="UTF-8"?>
<out_xml>
<Root>
<ItemCollection>
<Item name="BaseLineOffSet" type="2">
<Histogram>
<DispOrder>This is Order</DispOrder>
<IntensityArray>
<Intensity>105.84667205810547</Intensity>
<Intensity>105.83854675292969</Intensity>
<Intensity>105.57729339599609</Intensity>
<Intensity>105.66104888916016</Intensity>
<Intensity>105.56392669677734</Intensity>
<Intensity>105.33917236328125</Intensity>
<Intensity>105.33854675292969</Intensity>
<Intensity>105.31544494628906</Intensity>
<Intensity>105.40036010742187</Intensity>
<Intensity>105.21470642089844</Intensity>
<Intensity>105.14356994628906</Intensity>
<Intensity>104.92792510986328</Intensity>
<Intensity>104.93791961669922</Intensity>
<Intensity>104.93979644775391</Intensity>
<Intensity>104.96470642089844</Intensity>
<Intensity>105.01107025146484</Intensity>
<Intensity>104.76479339599609</Intensity>
<Intensity>104.9085693359375</Intensity>
<Intensity>104.70166778564453</Intensity>
<Intensity>104.75499725341797</Intensity>
<Intensity>104.77352905273437</Intensity>
<Intensity>104.77714538574219</Intensity>
<Intensity>104.59485626220703</Intensity>
<Intensity>104.73235321044922</Intensity>
<Intensity>104.35479736328125</Intensity>
<Intensity>104.56911468505859</Intensity>
<Intensity>104.38999938964844</Intensity>
<Intensity>104.30992889404297</Intensity>
<Intensity>104.37964630126953</Intensity>
</IntensityArray>
</Histogram>
</Item>
<Item name="DispIntervalsMaxValues" type="2">
<Histogram>
<DispOrder>This is Order</DispOrder>
<IntensityArray>
<Intensity>1.0229243040084839</Intensity>
<Intensity>48.868541717529297</Intensity>
<Intensity>47.504795074462891</Intensity>
<Intensity>162.17105102539062</Intensity>
<Intensity>91.323570251464844</Intensity>
<Intensity>44.405426025390625</Intensity>
<Intensity>51.243541717529297</Intensity>
<Intensity>131.44705200195312</Intensity>
<Intensity>2.8496425151824951</Intensity>
<Intensity>21.435295104980469</Intensity>
<Intensity>47.006423950195312</Intensity>
<Intensity>0.72917240858078003</Intensity>
<Intensity>46.669178009033203</Intensity>
<Intensity>83.804801940917969</Intensity>
<Intensity>44.197799682617187</Intensity>
<Intensity>32.138923645019531</Intensity>
<Intensity>30.30479621887207</Intensity>
<Intensity>58.928920745849609</Intensity>
<Intensity>29.930421829223633</Intensity>
<Intensity>38.282505035400391</Intensity>
<Intensity>30.801467895507813</Intensity>
<Intensity>43.710361480712891</Intensity>
<Intensity>38.167644500732422</Intensity>
<Intensity>27.842643737792969</Intensity>
<Intensity>34.102294921875</Intensity>
<Intensity>61.118381500244141</Intensity>
<Intensity>10.910002708435059</Intensity>
<Intensity>3.6150767803192139</Intensity>
<Intensity>3.1703603267669678</Intensity>
</IntensityArray>
</Histogram>
</Item>
</ItemCollection>
</Root>
</out_xml>
我真正想要的是将两个强度数组中的元素相加。因此,它可能是这样的:
FirstArray [0] + SecondArray [0] = sum [0],实际上是
105.84667205810547 + 1.0229243040084839 = 106.8696
并且
FirstArray [1] + SecondArray [1] = sum [1]
105.83854675292969 + 48.868541717529297 = 154.7071,依此类推...
现在我需要忽略这两个之间的一些其他项目。
谢谢!
<xsl:key>
定义,例如:<xsl:key name="k" match="//Item[@name = 'BaseLineOffSet' or @name = 'DispIntervalsMaxValues'] //Intensity" use="count(preceding-sibling::Intensity)"/>
。 - Kirill Polishchuk