On Sunday, February 3, 2002, at 09:45 AM, Brad Cox wrote:
One last glitch and I"m there. All xhtml markup is being stripped from $pageText.
This is driving me crazy. I'm still hung on the same problem. Can someone please help? Here's the nub of it:
<xsl:template match="page">
<xsl:variable name="body">
#parse("vel/macros.vel")
#taskOpening("@ident")
<xsl:apply-templates select="*"/>
#taskClosing("@ident")
</xsl:variable>
PageText{<xsl:value-of select="$body"/>}
<xsl:value-of select="task:addPage($task, @ident, $body)" />
</xsl:template>I've confirmed that the $body variable within the addPage routine contains only text minus markup. In particular, for
<task ident="HelloWorld">
<page ident="LoremIpsem">
<p>Foo</p>
</page>
</task>I'm seeing CopyOf{Foo} in the output when I should be seeing <p>CopyOf(<p>Foo</p>)</p>. It appears that markup is deleted when the results are saved in a variable. If I add a <xsl:apply-templates select="*"/> outside of the variable assignment in the above, the output contains markup as expected.
Here is the whole stylesheet.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:task="edu.virtualschool.model.Task"
extension-element-prefixes="task"
exclude-result-prefixes="java"
>
<xsl:output method="html"/>
<xsl:param name="task">null</xsl:param><xsl:template match="/task">
#set($totalPages = <xsl:value-of select="count(page)"/>)
#set($pageTitles = [<xsl:for-each select="page">"<xsl:value-of select="@ident"/>",</xsl:for-each>"Submit page"])
<xsl:apply-templates select="page"/>
</xsl:template>
<xsl:template match="page">
<xsl:variable name="body">
#parse("vel/macros.vel")
#taskOpening("@ident")
<xsl:apply-templates select="*"/>
#taskClosing("@ident")
</xsl:variable>
PageText{<xsl:value-of select="$body"/>}
<xsl:value-of select="task:addPage($task, @ident, $body)" />
</xsl:template><xsl:template match="EmailQuestion|EssayQuestion|NameQuestion|UrlQuestion|PhoneQuestion"
>
#<xsl:value-of select="name()"/>("<xsl:value-of select="@ident"/>" "<xsl:value-of select="normalize-
space(text())"/>")
</xsl:template>
<xsl:template match="MenuQuestion|RadioQuestion|CheckboxQuestion">
#<xsl:value-of select="name()"/>("<xsl:value-of select="@ident"/>" "<xsl:value-of select="normalize-
space(text())"/>" [<xsl:for-each select="option">"<xsl:value-of select="."/>"<xsl:if test="not(position() = last())">,</xsl:if></xsl:for-each>])
</xsl:template>
<xsl:template match="*">
<p>CopyOf{<xsl:copy-of select="."/>}</p>
</xsl:template></xsl:stylesheet>
