Subject: RE: [xsl] Preserve HTML formatting when apply-templates in variabl From: "Michael Kay" <mhk@xxxxxxxxx> Date: Fri, 6 Aug 2004 16:25:20 +0100 |
> The reason I did not include the last template is because I > was testing the > result of the template match "review" by writing out my > variable like this: > > <hr/> > <xsl:value-of select="$ui_review" disable-output-escaping="yes"/> > <hr/> > Just as Jeni suspected. She's good at finding bugs in code she can't see. Switch to using xsl:copy-of and all should be well. Michael Kay > Hence, no need for the rest of the code. In the above > example the HTML code > has all ready been lost and the "ui_review" variable just > spits out the text > result. In otherwords, my HTML tags are lost when I apply-templates > "review"... and the only way I found to preserve them is to > hide them fromt > the XSLT processor with CDATA elements within text blocks > (the appaling > stuff). > > I tried the following variable declerations: > > <xsl:variable name="$ui_review"> > <xsl:copy-of select="review"/> > </xsl:variable> > > <xsl:variable name="$ui_review"> > <xsl:value-of select="review"/> > </xsl:variable> > > (neither of the above work, I think they pull straight from the source > ignoring the template rule all together). > > Karl > > > > -----Original Message----- > From: Michael Kay [mailto:mhk@xxxxxxxxx] > Sent: Thursday, August 05, 2004 11:55 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: [xsl] Preserve HTML formatting when apply-templates in > variabl > > > > > > Wow! Some solution (that I came up with). The use of > > xsl:text and cdata > > elements is quite complex... would hate to apply something > > like this to a > > serious template match. Anyhow... is this the best way to > > accomplish what > > I'd like to accomplish (and it works)?: > > No, this is an appalling way to use XSLT. Go back to your > previous attempt > and find out where your mistake was. > > Michael Kay > > > > > > <xsl:template match="review"> > > <xsl:text><![CDATA[<img src="/images/arrow_2.jpg" > > alt="]]></xsl:text> > > <xsl:value-of select="title"/><xsl:text><![CDATA[" class="padr"/>]]> > > </xsl:text> > > <xsl:text><![CDATA[<h3 class="txt_1 inline > > bold">]]></xsl:text><xsl:value-of > > select="title"/><xsl:text><![CDATA[</h3>]]></xsl:text> > > <xsl:text><![CDATA[<p class="txt_1">]]></xsl:text><xsl:value-of > > select="content"/><xsl:text><![CDATA[</p>]]></xsl:text> > > > > <!-- link for more content --> > > <xsl:text><![CDATA[<div class="marginb"> > > <a href="]]></xsl:text><xsl:value-of > > select="link"/><xsl:text><![CDATA[>more <img > src="images/arrow_2.jpg" > > alt="]]></xsl:text><xsl:value-of > select="title"/><xsl:text><![CDATA[" > > width="13" height="7" border="0"/></a>]]></xsl:text> > > <xsl:text><![CDATA[</div>]]></xsl:text> > > > > </xsl:template> > > > > > > > > > > > > -----Original Message----- > > From: Karl J. Stubsjoen [mailto:karl@xxxxxxxxxxxxxxxxxxxx] > > Sent: Thursday, August 05, 2004 10:21 PM > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > Subject: [xsl] Preserve HTML formatting when apply-templates > > in variabl > > > > > > Hi there, > > I am trying to get the result of a template match as > > preserved HTML in my > > variable. I'm not to sure what is happening to the HTML, but > > I think it is > > just getting stripped. > > The variable which should retrieve the HTML from the matched > > template is > > "ui_review". The template "review" is responsible for > > generating the HTML. > > > > Here is what I have: > > > > <xsl:template match="uireview"> > > <xsl:variable name="ui_review"> > > <xsl:apply-templates select="review"/> > > </xsl:variable> > > > > <xsl:call-template name="ui_content"> > > <xsl:with-param name="title">UI Review</xsl:with-param> > > <xsl:with-param name="content" select="$ui_review"/> > > <xsl:with-param name="height">300</xsl:with-param> > > </xsl:call-template> > > > > </xsl:template> > > > > <xsl:template match="review"> > > <img src="/images/arrow_2.jpg" alt="{title}" class="padr"/> > > <h3 class="txt_1 inline bold"><xsl:value-of > > select="title"/></h3> > > <p class="txt_1"><xsl:value-of select="content"/></p> > > > > <!-- link for more content --> > > <div class="marginb"> > > <a href="{link}">more <img src="images/arrow_2.jpg" > alt="{title}" > > width="13" height="7" border="0"/></a> > > </div> > > <!-- horizontal "dashed" div tag --> > > <xsl:if test="not(position()=last())"> > > <div class="hr_1px_dashed" /> > > </xsl:if> > > > > </xsl:template> > > > > > > ========= end example ========== > > > > Thanks for the help! > > Karl
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Preserve HTML formatting , Chris Loschen | Thread | RE: [xsl] Preserve HTML formatting , Passin, Tom |
RE: [xsl] Linenumbering & word inde, Michael Kay | Date | RE: [xsl] Function JavaScript with , Michael Kay |
Month |