One of the most valuable concepts in the world of data and analytics is making data "readable" by both machines and humans.
Data that is only human-readable is great for cartoons, and endless lines of code is perfect for making software work. But the real magic happens when computers and humans get on the same page...
Enter XSLT
One of the easiest ways to understand what is XSLT (extensible stylesheet language transformations) is that it's simply a template for displaying specific information from more complex XML data sets.
The first step is getting data into XML format. Then, a tool that performs XSLT transformations can create documents with accurate data laid out in any given format or structure. The information in data sets is now understandable to humans and machines.
Here's an Example of How XML is Transformed into XSLT:
Step 1) Let's start with an XML document (text colors were added to make this easier to understand):
<?xml version="1.0" encoding="UTF-8"?>
<superlist>
<heroes>
<supername>Captain America</supername>
<alias>Steve Rogers</alias>
<born>New York City</born>
<year>1920</year>
</heroes>
<heroes>
<supername>Superman</supername>
<alias>Clark Kent, Kal-El</alias>
<born>Krypton</born>
<year>1938</year>
</heroes>
<heroes>
<supername>Wolverine</supername>
<alias>James Howlett</alias>
<born>Alberta, Canada</born>
<year>1832</year>
</heroes>
</superlist>
Step 2) And here is an XSLT Stylesheet that is a template for how to transform and display the XML document's information:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0">
<xsl:template match="/">
<html>
<body>
<h2>Super Heroes</h2>
<table border="1">
<tr bgcolor="#0293ed">
<th style="text-align:left">Super Name</th>
<th style="text-align:left">Alias</th>
<th style="text-align:left">Home</th>
<th style="text-align:left">Born in</th>
</tr>
<xsl:for-each select="superlist/heroes">
<tr>
<td><xsl:value-of select="supername"/></td>
<td><xsl:value-of select="alias"/></td>
<td><xsl:value-of select="born"/></td>
<td><xsl:value-of select="year"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Step 3) Finally, after running the documents through the XSLT processor, here is what the XML file now looks like on our computer display / monitor:
How XSLT Works
Here's another way to understand what is XSLT: it's similar to what happens behind the scenes to make websites readable. If you're curious, hit the F12 key on your keyboard to see all the code behind this article.
So if we can do the same thing as a website — take a whole lot of hard-to-understand data and present it in a way that's easy to understand — we will turn more data into actionable and valuable information.
The code that makes websites work is called HTML, and the code behind many electronic documents (including Microsoft Office) is called XML. XML separates information from the presentation layer. Basically, it is a language that defines what each piece of data is. This is very different than HTML.
In HTML a header tag (such as <h2>) is used to format text, but it doesn't say what that text is. But XML does specify what the text is. For example, <productCategory title="OCR Software for Oil and Gas"> defines exactly what the text represents.
Just like there are standards with website code, there are also standards for the way XML is formatted. There are specially defined characters, markup rules, tags, elements, attributes, etc. that all help to bring data to life. You can learn more about XML here.
Essentially, XML formats data so there can be no question about the information it represents. Once data is in an XML format it's no longer locked inside a proprietary computer language.
Here's where XSLT comes into play. Because XML is designed to separate data from the presentation of the information, it needs a bit of processing to become more transparent. Take a look at some XML code for a document below:
Exactly What is XSLT and What is its Use?
XSLT is a programming language used to transform that code into beautiful PDF documents, web pages, plain text, or even printer-friendly PostScript format. And the great thing is that the information can be arranged in virtually any desired layout.
With XSLT, information from multiple XML "documents" can even be combined into a single final document. This aids in the creation of dashboards and reports which must pull data from more than one source.
Because XML is so precisely formatted, it acts as a sort of "single version of the truth." The data contained in XML can be used to match and integrate information from external databases or document repositories.
Looking for an even deeper dive, other than 'What is XSLT'? look at this article or check out our data science solutions that work with XSLT files every day: