cancel
Showing results for 
Search instead for 
Did you mean: 

XML Simple Transformation read attributes

Andrzej97
Explorer
0 Kudos
136

Hi,

i've created Simple Transformation for following xml:

     <Fuel type="Diesel CI">
          <FuelConsumption unit="l/100km">23</FuelConsumption>
          <FuelConsumption unit="l/t-km">26</FuelConsumption>
          <FuelConsumption unit="l/m³-km">25</FuelConsumption>
          <FuelConsumption unit="g/km">11</FuelConsumption>
          <FuelConsumption unit="g/t-km">23</FuelConsumption>
          <FuelConsumption unit="g/m³-km">14</FuelConsumption>
        </Fuel>

Transformation looks as below:

     <Fuel>
        <tt:loop ref="FUEL">
              <FuelConsumption tt:value-ref="FuelConsumption">
              </FuelConsumption>
        </tt:loop>
      </Fuel>

Currently I am transforming the FuelConsumption values ​​(23,26,25...) to a table, which is fine, but I want to save the attribute unit as well. I have a table with two fields FuelConsumption and Unit. Do you know what the correct syntax would be? I have tried many options, but unfortunately none of them work.

 

Kind regards

View Entire Topic
Andrzej97
Explorer

I did find solution by myself finally. 

This syntax will do the job: 

           <Fuel>
              <tt:loop ref="FUEL">
                <FuelConsumption>
                  <tt:attribute name="unit" value-ref="$REF.unit"/>
                  <tt:value ref="FuelConsumption"/>
                </FuelConsumption>
              </tt:loop>
             </Fuel>