0 Replies Latest reply: Nov 21, 2011 1:22 AM by 901240 RSS

    Splitting xml message using XSLT

    901240
      Hi,

      I have XML message that I want to split up using XSLT. Following is the structure of the XML message.

      <Meters>
      <Meter>
      <ID>1</ID>
      <Type>A</Type>
      <Reading ref="1A" />
      </Meter>

      <Meter>
      <ID>2</ID>
      <Type>A</Type>
      <Reading ref="2A" />
      </Meter>

      <Meter>
      <ID>3</ID>
      <Type>B</Type>
      <Reading ref="3B" />
      </Meter>

      <Reading>
      <refLink>1A</refLink>
      <quantity>Watts</quantity>
      <value>221.00</value>
      </Reading>
      <Reading>
      <refLink>2A</refLink>
      <quantity>Wh d</quantity>
      <value>0.00</value>
      </Reading>
      <Reading>
      <refLink>3B</refLink>
      <quantity>Wh r</quantity>
      <value>3.00</value>
      </Reading>
      </Meters>

      The split up should happen on the <Meter> tag. Currently, this message has three <Meter> elements. The output should result in 3 different XML messages each having its own <Meter> element. Also, please note that each <Meter> has <Reading> which is linked to the actual <Reading> data using "ref" attribute and "refLink". The value of "ref" attribute will be unique through out the XML message.

      Expected output: 1.xml
      <Meters>
      <Meter>
      <ID>1</ID>
      <Type>A</Type>
      <Reading ref="1A" />
      </Meter>
      <Reading>
      <refLink>1A</refLink>
      <quantity>Watts</quantity>
      <value>221.00</value>
      </Reading>
      </Meters>

      and similarly 2 more XMLs.
      Please let me know if anyone has done this kind of work in XSLT.