Plunging into .NET Development

Weblog Pieter Gheysens
Microsoft .NET Development - C# - Enterprise Library - Visual Studio 2005 Team System - Compuware DevPartner - ...
 


Friday, May 20

into XSLT

The last two weeks I've been working intensively with XSLT (Extensible Stylesheet Language Transformation) to transform (serialized) XML documents into other XML documents. It was about time to refresh/update my knowledge about all this XML-related stuff! I knew what XSLT basically could do, but I really didn't have a lot of XSLT-syntax in my fingers ...
  • XML
    XML (Extensible Markup Language) is a standard for creating markup languages which describe the structure of data
  • XSL - XSLT
    XSLT (Extensible Stylesheet Language Transformation) is kind of an extension for XSL. XSL (Extentsible Stylesheet Language) specifies the styling (separating style from content) of an XML document by using XSLT to describe how the document is transformed into another document that uses the formatting vocabulary. First there was XSL, which was conceived as a language to do styling (how an XML document should be rendered). Then XSLT was carved out as a separate sub-language to do the first part of styling, which is transformation.
  • XPath
    XPath is a (query) language that describes how to locate specific elements (and attributes, processing instructions, etc.) in a document. It allows you to locate specific content within a XML document. XPath treats a XML document as a logical ordered tree. XPath information is processed using XSLT.
XML is nowadays widely used as a data interchange syntax and therefore the need for applications to convert data from one XML document to another format has increased a lot. XSLT is designed for doing these kind of transformations. It looks to me that an XSLT stylesheet for transforming XML can be made much more resilient to changes in the details of the XML documents than a programming language using the low-level Document Object Model interface [building XmlDocument in C# from scratch]. Changing an XSLT stylesheet is also much faster than recompiling and redeploying your entire application.

Unfortunately, the power and associated complexity of XSLT can be overwhelming at the beginning, preventing many from experimenting with it. I've learnt a lot from other examples (tutorials) and from best practices a colleague gave me. I also recommend using XMLSpy as editor for dealing with XML-related documents. The XMLSpy XSLT Debugger makes it easy to troubleshoot (step-by-step) and fix XSLT stylesheets. At the same time you have a clear view of the original XML, the xslt stylesheet in debug mode and the output as it is being generated in real-time.

Any ideas about performance of XSLT-tranformations? I should give this a closer look next week ...

0 Comments:

Post a Comment

<< Home