[thelist] info on templates, XML and TLAs

David.Cantrell at Gunter.AF.mil David.Cantrell at Gunter.AF.mil
Wed Feb 26 13:58:01 CST 2003


> styles AND different human languages). I've looked at Perl
> and PHP templates but I'd like to see how to do a "proper"
> xml template with *** (is it XSLT?).

YES! :)

> How do you make a "template" that includes other information
> (e.g. navigation)? Is this just XSL Transformations? Can you
> recommend any good articles on making templates? I understand
> the concepts of XML documents from my work with XHTML (I
> teach it and know how to read the DTD and know how to modify
> a DTD), I've not done transformations though.

Given the following blog entry XML:

<?xml version="1.0"?>
<entry>
	<pubDate>2003-02-26T13:50:00CST</pubDate>
	<title>This is my blog entry</title>
	<body>
		This is the main body of the entry. I can put anything here.
Phear my l33t skillz!
	</body>
</entry>

You can pipe the above through an XSLT stylesheet that might look like this:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
	<xsl:output method="html">

	<xsl:template match="/">
		<xsl:apply-templates select="/entry">
	</xsl:template>

	<xsl:template match="entry">
		<p class='entry'>
			<h2>
				<xsl:value-of select="title"/>
			</h2>
			<p class='pubDate'>
				<xsl:value-of select="pubDate"/>
			</p>
			<p class='body'>
				<xsl:value-of select="body"/>
			</p>
		</p>
	</xsl:template>
</xsl:stylesheet>

And the output given the above two documents would be this:

<p class='entry'>
	<h2>
		This is my blog entry.
	</h2>
	<p class='pubDate'>
		2003-02-26T13:50:00CST
	</p>
	<p class='body'>
		This is the main body of the entry. I can put anything here.
Phear my l33t skillz!
	</p>
</p>

There's tons of info on this available. Check these sites out:

	http://www.w3schools.com/xsl/default.asp
	http://www.zvon.org/xxl/XSLTutorial/Books/Book1/
	http://hotwired.lycos.com/webmonkey/98/43/index2a.html?tw=authoring

Then there's the DMOZ category:


http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/Style_Sheets/XSL
/FAQs,_Help,_and_Tutorials/

HTH,
-dave



More information about the thelist mailing list