2017-08-28 51 views
0

我需要找到mule中xml元素的sume。輸入XML看起來是這樣的:Mule - 找到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 *觀測值。嘗試使用數據編織,但沒有成功。在使用dataweave時,我無法評估。任何幫助將不勝感激。

回答

4

當數值ObsValue標籤使用@符號的屬性來獲得屬性值一樣,

%dw 1.0 
%output application/java 
--- 
sum (payload.MessageGroup.DataSet.Series.*[email protected]) 

輸出= 29.6

希望這有助於