XSLT 1.0 Basic Transformation Example

The following example shows a basic XSLT transformation from one XML to another with a different structure.



I’m assuming that the reader has the following skills:


Basic Transformation

Let’s begin with this XML:


And we want to transform it into a different XML, like this:


It’s the same data but in different order. To obtain this result, we need a XSLT transformation like this:



You can notice a few things about the XSLT above:

  • You have to write your new XML tree and populate it with the values of the old one.
  • The tag xsl:value-of select=”” is the basic selector for getting information about a node or attribute.
  • If you want to insert an attribute inside a node, follow the steps from line 29 to 31
  • To get the value of an attribute, add an @ before the name of the attribute. Look at line 10


3 comments: On XSLT 1.0 Basic Transformation Example

Leave a reply:

Your email address will not be published.

Copyright © 2016 Marco Tello.