|
December 28, 2001 Populating an HTML Template with XML Data Tips: December 2001
Yehuda Shiran, Ph.D.
|
|
To convert an XML file to HTML, you start by writing the skeleton of the HTML file, specifying all tags such as <BODY> and <H1>. The content between each pair of tags is selected by XML directives. Take a look at the following line:
It is written within matching HTML brackets, and it includes one XML tag: xsl:value of. This XML tag has also a switch, select, by which it matches XML data. In the above example, it searches for the <summary><subhead> combination. Here is the top portion of the XML file:
You can see that the value matching the above specification (//summary/subhead) is Periodical Sales Report. In a similar fashion, we find that //summary/heading is "MyDvd Rental Store", and that //summary/description is "Sales Report for January, February, and March of 2001". Here is the full XSLT file:
Load the XML and XSLT files onto your drive. Try reading the XML file in your browser. You will get the header of the sales report formatted and displayed like this:
People who read this tip also read these tips: Look for similar tips by subject: |