如何从一系列节点获取最大属性

时间:2019-04-02 14:25:39

标签: xml xpath

我正在为我的openhabian编写一些自定义代码。我已经实现了从XML的api获取数据。但是,如何使用xpath选择一系列节点的最大属性? 我正在尝试获取 value 的最大值,这是我在time/location/precipitation/value

下找到的属性

我已经阅读了两个文档:https://www.w3.org/TR/xpath-functions-31/#func-max,并研究了关于stackoverflow的类似问题。

我的XML


<weatherdata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://api.met.no/weatherapi/locationforecast/1.9/schema" created="2019-04-02T12:11:29Z">
<meta>
<model name="LOCAL" termin="2019-04-02T06:00:00Z" runended="2019-04-02T08:27:40Z" nextrun="2019-04-02T16:00:00Z" from="2019-04-02T13:00:00Z" to="2019-04-05T00:00:00Z"/>
<model name="EPS" termin="2019-04-02T00:00:00Z" runended="2019-04-02T09:15:12Z" nextrun="2019-04-02T22:00:00Z" from="2019-04-05T06:00:00Z" to="2019-04-11T18:00:00Z"/>
</meta>
<product class="pointData">
<time datatype="forecast" from="2019-04-02T13:00:00Z" to="2019-04-02T13:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="8.6"/>
<windDirection id="dd" deg="103.8" name="E"/>
<windSpeed id="ff" mps="6.2" beaufort="4" name="Laber bris"/>
<windGust id="ff_gust" mps="10.6"/>
<areaMaxWindSpeed mps="9.6"/>
<humidity value="58.4" unit="percent"/>
<pressure id="pr" unit="hPa" value="1010.6"/>
<cloudiness id="NN" percent="0.1"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="0.1"/>
<mediumClouds id="MEDIUM" percent="0.0"/>
<highClouds id="HIGH" percent="0.0"/>
<dewpointTemperature id="TD" unit="celsius" value="0.7"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T12:00:00Z" to="2019-04-02T13:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Sun" number="1"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T11:00:00Z" to="2019-04-02T13:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Sun" number="1"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T10:00:00Z" to="2019-04-02T13:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Sun" number="1"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T07:00:00Z" to="2019-04-02T13:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="5.0"/>
<maxTemperature id="TTT" unit="celsius" value="8.6"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T14:00:00Z" to="2019-04-02T14:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="8.6"/>
<windDirection id="dd" deg="99.9" name="E"/>
<windSpeed id="ff" mps="6.6" beaufort="4" name="Laber bris"/>
<windGust id="ff_gust" mps="11.1"/>
<areaMaxWindSpeed mps="10.6"/>
<humidity value="60.8" unit="percent"/>
<pressure id="pr" unit="hPa" value="1010.0"/>
<cloudiness id="NN" percent="8.8"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="0.0"/>
<mediumClouds id="MEDIUM" percent="0.0"/>
<highClouds id="HIGH" percent="8.8"/>
<dewpointTemperature id="TD" unit="celsius" value="1.3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T13:00:00Z" to="2019-04-02T14:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Sun" number="1"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T12:00:00Z" to="2019-04-02T14:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Sun" number="1"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T11:00:00Z" to="2019-04-02T14:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Sun" number="1"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T08:00:00Z" to="2019-04-02T14:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="5.6"/>
<maxTemperature id="TTT" unit="celsius" value="8.6"/>
<symbol id="LightCloud" number="2"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T15:00:00Z" to="2019-04-02T15:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="8.4"/>
<windDirection id="dd" deg="95.7" name="E"/>
<windSpeed id="ff" mps="6.6" beaufort="4" name="Laber bris"/>
<windGust id="ff_gust" mps="11.2"/>
<areaMaxWindSpeed mps="11.0"/>
<humidity value="61.4" unit="percent"/>
<pressure id="pr" unit="hPa" value="1009.4"/>
<cloudiness id="NN" percent="67.8"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="0.0"/>
<mediumClouds id="MEDIUM" percent="0.3"/>
<highClouds id="HIGH" percent="67.7"/>
<dewpointTemperature id="TD" unit="celsius" value="1.3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T14:00:00Z" to="2019-04-02T15:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T13:00:00Z" to="2019-04-02T15:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T12:00:00Z" to="2019-04-02T15:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="LightCloud" number="2"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T09:00:00Z" to="2019-04-02T15:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="6.3"/>
<maxTemperature id="TTT" unit="celsius" value="8.6"/>
<symbol id="LightCloud" number="2"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T16:00:00Z" to="2019-04-02T16:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="8.1"/>
<windDirection id="dd" deg="91.3" name="E"/>
<windSpeed id="ff" mps="6.3" beaufort="4" name="Laber bris"/>
<windGust id="ff_gust" mps="11.0"/>
<areaMaxWindSpeed mps="10.9"/>
<humidity value="63.5" unit="percent"/>
<pressure id="pr" unit="hPa" value="1008.7"/>
<cloudiness id="NN" percent="53.5"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="0.0"/>
<mediumClouds id="MEDIUM" percent="1.1"/>
<highClouds id="HIGH" percent="52.9"/>
<dewpointTemperature id="TD" unit="celsius" value="1.5"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T15:00:00Z" to="2019-04-02T16:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T14:00:00Z" to="2019-04-02T16:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T13:00:00Z" to="2019-04-02T16:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T10:00:00Z" to="2019-04-02T16:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="6.7"/>
<maxTemperature id="TTT" unit="celsius" value="8.6"/>
<symbol id="LightCloud" number="2"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T17:00:00Z" to="2019-04-02T17:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="7.8"/>
<windDirection id="dd" deg="88.9" name="E"/>
<windSpeed id="ff" mps="5.8" beaufort="4" name="Laber bris"/>
<windGust id="ff_gust" mps="10.3"/>
<areaMaxWindSpeed mps="10.5"/>
<humidity value="65.2" unit="percent"/>
<pressure id="pr" unit="hPa" value="1008.5"/>
<cloudiness id="NN" percent="31.8"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="0.0"/>
<mediumClouds id="MEDIUM" percent="1.2"/>
<highClouds id="HIGH" percent="30.9"/>
<dewpointTemperature id="TD" unit="celsius" value="1.5"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T16:00:00Z" to="2019-04-02T17:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="LightCloud" number="2"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T15:00:00Z" to="2019-04-02T17:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T14:00:00Z" to="2019-04-02T17:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T11:00:00Z" to="2019-04-02T17:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="7.8"/>
<maxTemperature id="TTT" unit="celsius" value="8.6"/>
<symbol id="LightCloud" number="2"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T18:00:00Z" to="2019-04-02T18:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="7.0"/>
<windDirection id="dd" deg="78.8" name="E"/>
<windSpeed id="ff" mps="4.4" beaufort="3" name="Lett bris"/>
<windGust id="ff_gust" mps="9.1"/>
<areaMaxWindSpeed mps="10.2"/>
<humidity value="68.9" unit="percent"/>
<pressure id="pr" unit="hPa" value="1008.3"/>
<cloudiness id="NN" percent="37.7"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="0.7"/>
<mediumClouds id="MEDIUM" percent="0.3"/>
<highClouds id="HIGH" percent="37.2"/>
<temperatureProbability unit="probabilitycode" value="0"/>
<windProbability unit="probabilitycode" value="0"/>
<dewpointTemperature id="TD" unit="celsius" value="1.5"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T17:00:00Z" to="2019-04-02T18:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="LightCloud" number="2"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T16:00:00Z" to="2019-04-02T18:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="LightCloud" number="2"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T15:00:00Z" to="2019-04-02T18:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T12:00:00Z" to="2019-04-02T18:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="7.0"/>
<maxTemperature id="TTT" unit="celsius" value="8.6"/>
<symbol id="LightCloud" number="2"/>
<symbolProbability unit="probabilitycode" value="0"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T19:00:00Z" to="2019-04-02T19:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="6.2"/>
<windDirection id="dd" deg="68.1" name="E"/>
<windSpeed id="ff" mps="3.9" beaufort="3" name="Lett bris"/>
<windGust id="ff_gust" mps="7.1"/>
<areaMaxWindSpeed mps="9.8"/>
<humidity value="70.8" unit="percent"/>
<pressure id="pr" unit="hPa" value="1008.3"/>
<cloudiness id="NN" percent="89.8"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="30.4"/>
<mediumClouds id="MEDIUM" percent="14.5"/>
<highClouds id="HIGH" percent="87.4"/>
<dewpointTemperature id="TD" unit="celsius" value="1.1"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T18:00:00Z" to="2019-04-02T19:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T17:00:00Z" to="2019-04-02T19:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T16:00:00Z" to="2019-04-02T19:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T13:00:00Z" to="2019-04-02T19:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="6.2"/>
<maxTemperature id="TTT" unit="celsius" value="8.6"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T20:00:00Z" to="2019-04-02T20:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="6.3"/>
<windDirection id="dd" deg="71.7" name="E"/>
<windSpeed id="ff" mps="4.4" beaufort="3" name="Lett bris"/>
<windGust id="ff_gust" mps="7.2"/>
<areaMaxWindSpeed mps="9.9"/>
<humidity value="66.9" unit="percent"/>
<pressure id="pr" unit="hPa" value="1008.0"/>
<cloudiness id="NN" percent="99.2"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="53.3"/>
<mediumClouds id="MEDIUM" percent="45.8"/>
<highClouds id="HIGH" percent="96.6"/>
<dewpointTemperature id="TD" unit="celsius" value="0.4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T19:00:00Z" to="2019-04-02T20:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T18:00:00Z" to="2019-04-02T20:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T17:00:00Z" to="2019-04-02T20:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T14:00:00Z" to="2019-04-02T20:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="6.2"/>
<maxTemperature id="TTT" unit="celsius" value="8.6"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T21:00:00Z" to="2019-04-02T21:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="6.0"/>
<windDirection id="dd" deg="67.3" name="NE"/>
<windSpeed id="ff" mps="4.8" beaufort="3" name="Lett bris"/>
<windGust id="ff_gust" mps="7.9"/>
<areaMaxWindSpeed mps="10.2"/>
<humidity value="69.7" unit="percent"/>
<pressure id="pr" unit="hPa" value="1007.8"/>
<cloudiness id="NN" percent="99.6"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="57.5"/>
<mediumClouds id="MEDIUM" percent="84.6"/>
<highClouds id="HIGH" percent="89.3"/>
<dewpointTemperature id="TD" unit="celsius" value="0.7"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T20:00:00Z" to="2019-04-02T21:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T19:00:00Z" to="2019-04-02T21:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T18:00:00Z" to="2019-04-02T21:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T15:00:00Z" to="2019-04-02T21:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="6.0"/>
<maxTemperature id="TTT" unit="celsius" value="8.4"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T22:00:00Z" to="2019-04-02T22:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="5.9"/>
<windDirection id="dd" deg="66.2" name="NE"/>
<windSpeed id="ff" mps="5.4" beaufort="3" name="Lett bris"/>
<windGust id="ff_gust" mps="8.8"/>
<areaMaxWindSpeed mps="11.2"/>
<humidity value="68.7" unit="percent"/>
<pressure id="pr" unit="hPa" value="1007.3"/>
<cloudiness id="NN" percent="100.0"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="57.8"/>
<mediumClouds id="MEDIUM" percent="99.8"/>
<highClouds id="HIGH" percent="76.5"/>
<dewpointTemperature id="TD" unit="celsius" value="0.4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T21:00:00Z" to="2019-04-02T22:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T20:00:00Z" to="2019-04-02T22:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T19:00:00Z" to="2019-04-02T22:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T16:00:00Z" to="2019-04-02T22:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="5.9"/>
<maxTemperature id="TTT" unit="celsius" value="8.1"/>
<symbol id="PartlyCloud" number="3"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T23:00:00Z" to="2019-04-02T23:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="5.9"/>
<windDirection id="dd" deg="64.4" name="NE"/>
<windSpeed id="ff" mps="6.1" beaufort="4" name="Laber bris"/>
<windGust id="ff_gust" mps="10.1"/>
<areaMaxWindSpeed mps="13.2"/>
<humidity value="66.6" unit="percent"/>
<pressure id="pr" unit="hPa" value="1006.7"/>
<cloudiness id="NN" percent="99.5"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="54.0"/>
<mediumClouds id="MEDIUM" percent="98.6"/>
<highClouds id="HIGH" percent="35.6"/>
<dewpointTemperature id="TD" unit="celsius" value="-0.0"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T22:00:00Z" to="2019-04-02T23:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T21:00:00Z" to="2019-04-02T23:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T20:00:00Z" to="2019-04-02T23:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T17:00:00Z" to="2019-04-02T23:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="5.9"/>
<maxTemperature id="TTT" unit="celsius" value="7.8"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-03T00:00:00Z" to="2019-04-03T00:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="5.7"/>
<windDirection id="dd" deg="60.0" name="NE"/>
<windSpeed id="ff" mps="6.0" beaufort="4" name="Laber bris"/>
<windGust id="ff_gust" mps="10.1"/>
<areaMaxWindSpeed mps="14.0"/>
<humidity value="65.6" unit="percent"/>
<pressure id="pr" unit="hPa" value="1006.1"/>
<cloudiness id="NN" percent="97.3"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="9.1"/>
<mediumClouds id="MEDIUM" percent="89.2"/>
<highClouds id="HIGH" percent="69.0"/>
<temperatureProbability unit="probabilitycode" value="0"/>
<windProbability unit="probabilitycode" value="0"/>
<dewpointTemperature id="TD" unit="celsius" value="-0.4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T23:00:00Z" to="2019-04-03T00:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T22:00:00Z" to="2019-04-03T00:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T21:00:00Z" to="2019-04-03T00:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T18:00:00Z" to="2019-04-03T00:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="5.7"/>
<maxTemperature id="TTT" unit="celsius" value="7.0"/>
<symbol id="Cloud" number="4"/>
<symbolProbability unit="probabilitycode" value="0"/>
</location>
</time>
<time datatype="forecast" from="2019-04-03T01:00:00Z" to="2019-04-03T01:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<temperature id="TTT" unit="celsius" value="5.3"/>
<windDirection id="dd" deg="58.9" name="NE"/>
<windSpeed id="ff" mps="6.4" beaufort="4" name="Laber bris"/>
<windGust id="ff_gust" mps="10.6"/>
<areaMaxWindSpeed mps="14.7"/>
<humidity value="67.1" unit="percent"/>
<pressure id="pr" unit="hPa" value="1005.5"/>
<cloudiness id="NN" percent="100.0"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="12.9"/>
<mediumClouds id="MEDIUM" percent="62.8"/>
<highClouds id="HIGH" percent="99.7"/>
<dewpointTemperature id="TD" unit="celsius" value="-0.5"/>
</location>
</time>
<time datatype="forecast" from="2019-04-03T00:00:00Z" to="2019-04-03T01:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T23:00:00Z" to="2019-04-03T01:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T22:00:00Z" to="2019-04-03T01:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
<time datatype="forecast" from="2019-04-02T19:00:00Z" to="2019-04-03T01:00:00Z">
<location altitude="7" latitude="58.1461" longitude="7.9957">
<precipitation unit="mm" value="0.0" minvalue="0.0" maxvalue="0.0"/>
<minTemperature id="TTT" unit="celsius" value="5.3"/>
<maxTemperature id="TTT" unit="celsius" value="6.3"/>
<symbol id="Cloud" number="4"/>
</location>
</time>
...

xpath

//time/location/precipitation[@value= max(../precipitation/@value)]/@value

我想获得最大值,但我却获得了所有值。 例如,请参见此处:http://xpather.com/6I4dKpnj

1 个答案:

答案 0 :(得分:0)

您的XML文件与您提供给在线工具的XML文件不同,因此它不是完整的最小和完整可验证示例

使用在线工具中的XML,正确的XPath表达式为

max(//time/location/precipitation/@value)

结果是

5.9

因此,一个有效的模板可能就是这个

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" />
    <xsl:template match="/">
        <xsl:value-of select="max(//time/location/precipitation/@value)" />
    </xsl:template>
</xsl:stylesheet>

其输出如前所述。