RE: [xsl] Thinking Out loud - XML or XSL for boiler messages

Subject: RE: [xsl] Thinking Out loud - XML or XSL for boiler messages
From: "Jim Fuller" <jim.fuller@xxxxxxxxxxxxxx>
Date: Sun, 29 Feb 2004 20:12:29 -0000
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Karl J. Stubsjoen
> Sent: 29 February 2004 15:52
> Subject: [xsl] Thinking Out loud - XML or XSL for boiler messages

> The XML problem:
> If messages are stored in a simple XML document, then I face 
> the challenge of how to insert additional information into 
> the XML when transforming.  For
> example:  the messages are generic, and might look like this 
> in the xml source.. "Dear [first_name], we apologize in the 
> delay for blah blah.." where [first_name] needs to be 

xml file
<?xml version="1.0" ?>
<resource>
<para>Dr <firstname/>, Please read this letter</para>
</resource>	

xsl file
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method = "html"/>
	<xsl:template match="resource">	
		<html>
			<title></title>
			<body>
			<xsl:apply-templates select="para"/>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="para">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="firstname">
		Jim
	</xsl:template>
</xsl:stylesheet>

Will print out 

<html>
<title></title>
<body>Dr 
		Jim
	, Please read this letter</body>
</html>

Don't worry about the whitespace for now,

This method can be extended which takes in data via xsl:param, so u
would define an <xsl:param name="firstname"/> and pass the value to the
XSLT processor, then this would result in a simple amendment of
firstname matching template

<xsl:template match="firstname">
	<xsl:value-of select="$firstname"/>
</xsl:template>

More modularity can be achieved by having these matching templates in a
separate xslt file and then use xsl:import or xsl:include to bring them
into your stylesheets.

This is just one simple way of doing it, there are a few other more
extensible methods, for example you could define all your data in
multiple xml files....

gl, Jim Fuller


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread