Subject: RE: [xsl] Poorly Formed HTML inside XSL Stylesheet From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Mon, 26 Nov 2001 22:29:27 -0000 |
Basically, the way you've outlined this doesn't fit the XSLT processing model at all. You've got one template that produces lots of start tags, and another that produces the corresponding end tags. This goes completely against the theoretical model, which is that XSLT is producing a tree, not a serial output file. Writing one node to the result tree is an atomic operation, you can't split it into two halves. So you need to do some radical restructuring. If it's as simple as your example, this isn't too difficult, you just need to rewrite it as: <xsl:template match="note"> <xsl:call-template name="contentWrapper"/> </xsl:template> <xsl:template name="contentWrapper"> <table> <tr><td><img src="j.jpg"></td> <td align=left> <xsl:copy-of select="."/> </td></tr></table> </xsl:template> In a more complex situation, you might have to pass a parameter to the template. But usually xsl:apply-templates does the job automatically for you. Mike Kay > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Kevin > Holbrook > Sent: 26 November 2001 21:24 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Poorly Formed HTML inside XSL Stylesheet > > > Hello All, > > I am in the process of writing stylesheets to transform structured XML > documents into an existing HTML structure. > > The problem I face is that I have to include massive amounts > of dirty HTML > around my XML data, and my manager wants the HTML to be > placed in separate > templates which provide a degree of separation between the > markup and the > data, WITHOUT using ![CDATA. > > So, I have the following setup. > > Source XML: > <note>stuff</note> > > My XSL: > <xsl:template name="preContentHeader"> > <xsl:text><![CDATA[ > <table> > <tr><td><img src="j.jpg"></td> > <td align=left> > ]]></xsl:text> > </xsl:template> > > <xsl:template name="postContentFooter"> > <xsl:text><![CDATA[ > </td></tr></table> > ]]></xsl:text> > </xsl:template> > > <xsl:template match="note"> > <xsl:call-template name="preContentHeader"/> > <xsl:copy-of select="."/> > <xsl:call-template name="postContentFooter"/> > </xsl:template> > > > Resulting HTML: > <table> > <tr> > <td><img src="j.jpg"></td> > <td align=left>stuff</td> > </tr></table> > > Any ideas of how I can do this without using ![CDATA? > > Thanks in advance, > > -Kevin > > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp 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 -> |
---|---|---|
[xsl] Poorly Formed HTML inside XSL, Kevin Holbrook | Thread | [xsl] how to output previous and ne, Uslu, Cihan Y (MED) |
RE: [xsl] Creating a container?, Michael Kay | Date | RE: [xsl] xsl and SSL, timw |
Month |