[thelist] info on templates, XML and TLAs
David.Cantrell at Gunter.AF.mil
David.Cantrell at Gunter.AF.mil
Wed Feb 26 14:58:01 CST 2003
> And XSL Transformations are sexier than PHP and Perl
> templates, right? (That's mostly a /rhetorical/ question.) I
> personally think it's silly to use PHP and Perl templates
> when there's a perfectly good XML template language out
> there. I also think it'll be easier to make the templates for
> my site if people aren't having to learn how to use
> "proprietary" (for lack of a better term) short cuts like
> those found in moveable type. (Which was my first idea...)
> It's a theory anyway.
Well, it depends. I'm not familiar with PHP or Perl templates at all, but to
me the whole point of XML+XSLT is that you can separate the logic from the
presentation. XSLT transforms the XML into HTML for the presentation, and
server-side logic can generate the XML in-memory or load it from a file,
manipulate it, etc until ready to be transformed.
I do it like this in ASP:
<%
Option Explicit
Dim Xml : Set Xml = Server.CreateObject ( "Msxml2.DomDocument.4.0" )
Xml.load Server.MapPath ( "foo.xml" )
Dim Xsl : Set Xsl = Server.CreateObject ( "Msxml2.DomDocument.4.0" )
Xsl.load Server.MapPath ( "style.xslt" )
Response.Write Xml.TransformXml ( Xsl )
%>
Actually, I use a helper VBScript class that does most of the grunt work for
me:
<%
Option Explicit
%>
<!--#include file="class.XmlUtilsObject.asp"-->
<%
Dim XmlUtils : Set XmlUtils = New XmlUtilsObject
Response.Write XmlUtils.TransformXml ( "foo.xml", "style.xslt" )
%>
And I also take recordsets and convert them in-memory to basic XML
structures and run those through XSLT to generate the HTML.
What does this mean? No more ASP/VBScript code mixed in with markup --
markup stays with markup, code stays with code, a place for everything and
everything in it's place.
It works remarkably well, for what I do at least.
-dave
More information about the thelist
mailing list