[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Need help with apply-templates to set variables
This is driving me crazy. I've been hung on this problem all
day. Could someone please help? I'm trying to use a xalan
extension to call one of my java functions. The extension logic
is working and the function is being called ok. The problem is
that it only gets the text content of each node. All xhtml
markup is being removed.
Here's the nub the problem. See below for the full stylesheet. <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> When $body is received (as a String) by my addPage routine, it contains only text with all markup removed. For example, for this input <task ident="HelloWorld"> <page ident="LoremIpsem"> <p>Foo</p> </page> </task> I see CopyOf{Foo} in the output when I want to be seeing <p>CopyOf(<p>Foo</p>)</p>. It seems that markup is deleted only 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> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|