我需要在mule中找到xml元素的sume。输入xml如下所示:
<message:MessageGroup
xmlns:message="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"
xmlns="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/generic"
xmlns:common="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/common"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/generic http://www.sdmx.org/docs/2_0/SDMXGenericData.xsd http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message http://www.sdmx.org/docs/2_0/SDMXMessage.xsd">
<Header xmlns="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message">
<ID>none</ID>
<Test>false</Test>
<Truncated>false</Truncated>
<Prepared>2017-08-28T05:35:50</Prepared>
<Sender id="ABS">
<Name xml:lang="en">Australian Bureau of Statistics</Name>
<Name xml:lang="fr">Australian Bureau of Statistics</Name>
</Sender>
</Header>
<DataSet
keyFamilyURI="http://stat.data.abs.gov.au/restsdmx/sdmx.ashx/GetKeyFamily/CPI">
<KeyFamilyRef>CPI</KeyFamilyRef>
<Series>
<SeriesKey>
<Value concept="MEASURE" value="3" />
<Value concept="REGION" value="50" />
<Value concept="INDEX" value="10001" />
<Value concept="TSEST" value="10" />
<Value concept="FREQUENCY" value="Q" />
</SeriesKey>
<Attributes>
<Value concept="TIME_FORMAT" value="P3M" />
</Attributes>
<Obs>
<Time>2001-Q1</Time>
<ObsValue value="6" />
</Obs>
<Obs>
<Time>2001-Q2</Time>
<ObsValue value="6.1" />
</Obs>
<Obs>
<Time>2001-Q3</Time>
<ObsValue value="2.5" />
</Obs>
<Obs>
<Time>2001-Q4</Time>
<ObsValue value="3.1" />
</Obs>
<Obs>
<Time>2002-Q1</Time>
<ObsValue value="3" />
</Obs>
<Obs>
<Time>2002-Q2</Time>
<ObsValue value="2.8" />
</Obs>
<Obs>
<Time>2002-Q3</Time>
<ObsValue value="3.2" />
</Obs>
<Obs>
<Time>2002-Q4</Time>
<ObsValue value="2.9" />
</Obs>
</Series>
<Annotations>
<common:Annotation>
<common:AnnotationTitle>Statistical usage warning
</common:AnnotationTitle>
<common:AnnotationText>
ABS.Stat beta is continuing to be developed. Data will be updated as soon
as possible following its 11:30 am release on the ABS website.
</common:AnnotationText>
</common:Annotation>
</Annotations>
</DataSet>
在这里,我需要对元素进行总结: ,其中包含: MessageGroup.DataSet.Series。* Obs 。尝试使用dataweave,但没有成功。使用dataweave时,我无法评估。任何帮助将不胜感激。
答案 0 :(得分:4)
由于值是ObsValue标签的属性,因此使用@符号获取属性值,如
%dw 1.0
%output application/java
---
sum (payload.MessageGroup.DataSet.Series.*Obs.ObsValue.@value)
输出= 29.6
希望这有帮助