Over a million developers have joined DZone.

Some Basics on XSLT Transformation

DZone's Guide to

Some Basics on XSLT Transformation

· Integration Zone ·
Free Resource

SnapLogic is the leading self-service enterprise-grade integration platform. Download the 2018 GartnerMagic Quadrant for Enterprise iPaaS or play around on the platform, risk free, for 30 days.

This post will elucidate some basic concerns for development of XSLT scripts. While I was writing some script for a wso2 ESB XSLT transformation I decided that this process would be a useful one to share.

Firstly I will point out some XSLT Elements

template  Rules to apply when a specified node is matched and it is a top-level element. But I like to used as function and call it and reuse it. Such like java or JavaScript or C# or ruby we can pass some parameters for that method also and use them in there.

<xsl:template name="get_age">
<xsl:param name="age" select="'%str'" />
<age><xsl:value-of select="$age"/></age>

you can call this get_age from XSLT

<xsl:call-template name="get_unique_value"> 
<xsl:with-param name="age"  select="//students/james/age/node()" />

Commenting also input after xslt generate it output. In there you like to see some comments

  Here I am writing a comment for my out transformation.

If Input XML if we have age for student name (james) write it for output. Only the age file not the parent tags.

<xsl:if test="//students/james/age!='' ">
<age><xsl:copy-of select="//students/james/age/node()"/></age>

for-each Student will have age and we need each age for each student. Element loops through each node in a specified node set.

<xsl:for-each select="//students”>
<age><xsl:copy-of select="//students/james/age/node()"/></age>

choose school for student age

  <xsl:when test="age>'10'">
Next post I will write some XSLT Functions 

With SnapLogic’s integration platform you can save millions of dollars, increase integrator productivity by 5X, and reduce integration time to value by 90%. Sign up for our risk-free 30-day trial!


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}