0

I'm using the DataMapper component in MuleStudio. I want to transform data that I have in this format

<item type="1" name="data">
    <children name="action">
        <values>login.01</values>
    <children>
</item>

to something like this

<item>
    <action>login.01</action>
</item>

Is this possible through Mule? Or will I need to make a custom Java parser?

Narabhut
  • 839
  • 4
  • 13
  • 30

1 Answers1

2

Assuming the source is XML, no need to use DataMapper: a simple XSL-T transformer will do the trick:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="item">
    <item>
      <xsl:apply-templates />
    </item>
  </xsl:template>

  <xsl:template match="children">
    <xsl:element name="{@name}">
      <xsl:apply-templates select="values/text()" />
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
David Dossot
  • 33,403
  • 4
  • 38
  • 72