• XSLT

    Posted on August 10th, 2009

    Written by douglaspaulwade

    Tags

    , ,

    I recently returned from an XSLT class taught by G. Ken Holman of Crane Softwrights. The class was five days training on XSLT, XQuery, and XPath. The class took place in Walnut Creek, California, August 3-7th, 2009. This was very intense. It was like trying to get a drink of water out of a fire hose. Ken covered every aspect of the specifications. The class was so over whelming that Joe (my co-worker) and I, being newbies, were clearly out classed. Most of the students had taken the class before, and one gentlemen just took it a month ago.

    Being a newbie, I am going to post items on transformations that are not about covering everything in the specification; there are plenty of books that cover that. I want to give easy-to-follow examples which can be used in converting documents from one flavor of XML to another. I will not cover creating HTML pages or other outputs from these transformations.

    I am no expert, but posting about a subject will help me improve upon writing XSLT. Being that I have a publishing background, I favor XSLT over XQuery (used more for machine-to-machine conversions).

    From my IDE, I will be using <oXygen/>. I prefer it because it has a XSLT debugger, and boy, do I need it. It has several XSLT processors, like Xalan, and Saxon and Saxon-SA (Schema Aware) built in. For my source file, I will be using a S1000D Schema document, which all of the text node (words) have been changed to “x”s. That transformation will be posted in upcoming post. This is to protect the data and not display the content, so it does not take on any significance or meaning. If you are interested, <oXygen> has a 30 day free trial version, and/or you can purchase the Academic or Non-Commercial version for $64.

    XSL stands for EXtensible Stylesheet Language and is a style sheet language for XML documents. XSLT stands for XSL Transformations. You can use XSLT to transform XML documents into other formats such as other XML documents, HTML, XHTML, and using XSLT-FO (format objects) transform XML to PDF, for example.

    The specification is at version 2.0 (2.1 is coming soon), but not all vendors fully support 2.0, as of yet. The specification version 1.0 has been around for some time, and since I am new all of my examples will be in version 2.0, why learn version 1.0 when 2.0 is clearly more verbose.

    XSLT is an XML (version 1.0) document. It must be well formed and valid. Below is an example of XSLT stylesheet used to transform an XML document. While it is valid, the stylesheet does not do much; its only output is: <?xml version=”1.0″ encoding=”UTF-8″?>.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     exclude-result-prefixes="xs"
     version="2.0">

     <xsl:template match="/" />

    </xsl:stylesheet>

    This entry was posted on Monday, August 10th, 2009 at 6:50 am and is filed under XSLT. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
  • 1 Comment

    Take a look at some of the responses we have had to this article.

    1. maxpensyl
      Aug 12th

      Let me know if you’d like any assistance in this. When I took Ken’s class I felt the same way you did. XSLT is a great language to know, and the possibilities are endless.

      Maxine

  • Leave a Reply

    Let us know what you thought.

  • Name(required):

    Email(required):

    Website:

    Message: