[Previous] [Contents] [Next]

Transforming XML Using XSL

An XSL document is very similar to an ASP or JSP document in that it can contain a mixture of text (usually XHTML) and scripting code. The XSL document can contain HTML code that will be displayed in a browser and programming instructions that can transform information in an XML document. Putting these two together, you can transform any XML document into XHTML.

To transform the BizTalk document above into XHTML, you will need to add a processing instruction declaring the location of the XSL document that will be used to transform this XML document. To accomplish this, add the following processing instruction to the top of the NorthwindPO.xml document after the XML declaration:


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

The type attribute declares that the document referenced by the href attribute is a style sheet and should be used to determine the styles for the elements in the HTML document.

You now need to create the NorthwindPO.xsl document. The XSL document will be a well-formed XML document. In its simplest form, the content of the XSL document is shown in the following code:


  <?xml version="1.0"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
     <xsl:template match="/">
        <xsl:value-of />
     </xsl:template>
  </xsl:stylesheet>

As you can see, the XSL template in this example is defined using a small set of XML elements. We'll have a detailed discussion of these elements in the next section.

[Previous] [Contents] [Next]