XSL Transformation is widly known tecnique for converting XML files to XHTML output. XSLT is designed for use as part of XSL, which is a stylesheet language for XML. XSL specifies the styling of an XML document by using XSLT to describe how the document is transformed into another XML document that uses the formatting vocabulary.
Here is sample XML document that will be used further.
Here is sample XSL Transformation
By using following sample c# code we can effectivly load xml document, and transform it's content into xhtml by using given xslt transformation:
Now since we know how to transform xml data with xsl stylesheet and produce valid html code, we can continue with introducing XSL Extension Objects.
Extension objects are used to extend the functionality of style sheets. Extension objects are maintained by the XsltArgumentList class.
The following are advantages to using an extension object rather than embedded script:
XSLT extension objects are added to the XsltArgumentList object using the AddExtensionObject method. A qualified name and namespace URI are associated with the extension object at that time. In this example we are using ResourceReader object
Let's add this object to XsltArgumentList so we can use latter in xsl transformation for reading string values from resources
And modified xslt stylesheet will look like this
And the rest is history. Cheers!