How about something like:

<xsl:template match="page">

  <xsl:variable name="someName">
    <xsl:apply-templates/>
  </xsl:variable>

  <xsl:value-of select="task:addPage($task, string(@ident), $someName)">

</xsl:template>

The type of $someName should be an XRTreeFrag, I believe.

As far as the optional first argument, neither of those types is used
for extension functions.  These are for extension elements.  You can
specify an optional ExpressionContext as the first argument if you need
any of its methods.

HTH,
Gary

> -----Original Message-----
> From: Brad Cox [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, February 02, 2002 7:20 PM
> To: [EMAIL PROTECTED]
> Cc: Brad Cox; Frank E. Weiss
> Subject: xalan extensions, cont'd.
> 
> 
> More on the previously posted question. After considerable 
> tinkering, the code is actually running, invoking the 
> addPage(key, value) method on the task instance I passed as a 
> parameter as intended.
> 
> The problem is that the value argument, as computed as 
> "string(.)", isn't what I want. I want the value to be the 
> result of <xsl:apply-templates/>, e.g. not the current node from 
> the input, but the node after being transformed by the other 
> templates in this file. I don't see how to do this. Can someone 
> please help?
> 
> Here's the full xsl file I'm using:
> 
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
>       xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>       xmlns:lxslt="http://xml.apache.org/xslt";
>       xmlns:java="http://xml.apache.org/xslt/java";
>       xmlns:task="edu.virtualschool.model.Task"
>       extension-element-prefixes="task"
>       exclude-result-prefixes="java"
>  >
> <xsl:output method="html"/>
> <xsl:param name="task"></xsl:param>
> 
> <xsl:template match="/task">
> #parse("vel/macros.vel")
> #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:value-of select="task:addPage($task, string(@ident), 
> string(.))" /> </xsl:template>
> 
> <xsl:template 
> match="EmailQuestion|EssayQuestion|NameQuestion|UrlQuestion">
> #<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="*">
> <xsl:copy-of select="."/>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> For completeness, the code that launches the transform (from 
> Task.java)
> 
> TransformerFactory tFactory = 
> TransformerFactory.newInstance(); Transformer transformer = 
> tFactory.newTransformer(new 
> StreamSource(xslFile.toString()));
> transformer.setParameter( "task", this );
> StringWriter sw = new StringWriter();
> transformer.transform(
>       new StreamSource(xmlFile.toString()),
>       new StreamResult(sw)
> );
> System.err.println("out:"+sw); // printed and discarded 
> this.xmlModified = xmlFile.lastModified(); this.dvslModified 
> = dvslFile.lastModified();
> 
> And the addPage method (from Task.java). I don't understand the 
> first two arguments; apparently they aren't needed/required/used 
> based on it working after commenting them
> out.
> 
>       public void addPage(
>               // 
> org.apache.xalan.extensions.XSLProcessorContext context,
>               // org.apache.xalan.templates.ElemExtensionCall element,
>               String ident,
>               String body
>       )
>       {
>               String pageText =
>                       "#parse(\"vel/macros.vel\")\n"+
>                       "#taskOpening(\""+ident+"\")\n"+
>                       body+"\n"+
>                       "#taskClosing(\""+ident+"\")\n"+
>                       "";
>               System.err.println("addPage:"+pageText);
>               pages.add(new Page(this, ident, pageText, new 
> IntegerField(pages.size())));
>       }
> 

Reply via email to