Overview of XSL Transformations

Overview of XSL Transformations
In an XSL transformation, an XSLT processor reads both an XML document and an XSLT style sheet. Based on the instructions the processor finds in the XSLT style sheet, it outputs a new XML document or fragment thereof.
There’s also special support for outputting HTML. With some effort most XSLT processors can also be made to output essentially arbitrary text, though XSLT is designed primarily for XML-to-XML and XML-to-HTML transformations.
Every well-formed XML document is a tree. A tree is a data structure composed of connected nodes beginning with a top node called the root. The root is connected to its child nodes, each of which is connected to zero or more children of its own, and so forth. Nodes that have no children of their own are called leaves.
A diagram of a tree looks much like a genealogical descendant chart that lists the descendants of a single ancestor. The most useful property of a tree is that each node and its children also form a tree. Thus, a tree is a hierarchical structure of trees in which each tree is built out of smaller trees.
For the purposes of XSLT, elements, attributes, namespaces, processing instructions, and comments are counted as nodes. Furthermore, the root of the document must be distinguished from the root element.
Thus, XSLT processors model an XML document as a tree that contains seven kinds of nodes:
• The root

• Elements

• Text

• Attributes

• Namespaces

• Processing instructions

• Comments

The Document Type Definition (DTD) and document type declaration are specifically not included in this tree. However, a DTD may add default attribute values to some elements, which then become additional attribute nodes in the tree.
<?xml version="1.0"?>

<?xml-stylesheet type="text/xml" href="sample.xsl"?>


  <atom state="gas">





    <boiling_point units="kelvin">20.28</boiling_point>

    <melting_point units="kelvin">13.81</melting_point>

    <density units="grams/cubic centimeter">

      <!-- at 300k, 1 atm -->




  <atom state="gas">





    <boiling_point units="kelvin">4.216</boiling_point>

    <melting_point units="kelvin">0.95</melting_point>

    <density units="grams/cubic centimeter"><!-- at 300k -->




Scroll to Top