Subject: RE: [xsl] Thinking Out loud - XML or XSL for boiler messages From: "Karl J. Stubsjoen" <karl@xxxxxxxxxxxxx> Date: Sun, 29 Feb 2004 14:45:25 -0700 |
Precisely what I was looking for... I've asked similar question before, but because the data I was retrieving was wrapped within an attribute this sort of template processing would not work. At this point, I do not have this trouble, the XML source is 100% my conception (the other is an ADO XML recordset). Thanks Jim... will put this to use now! Karl -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Jim Fuller Sent: Sunday, February 29, 2004 1:12 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Thinking Out loud - XML or XSL for boiler messages > [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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Thinking Out loud - XML o, Jim Fuller | Thread | Re: [xsl] Thinking Out loud - XML o, Robert Koberg |
RE: [xsl] table/matrix and xpath pr, Américo Albuquerque | Date | Re: [xsl] Thinking Out loud - XML o, Robert Koberg |
Month |