DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18086>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18086

XSLTC fails on java extension functions using NodeIterator args

           Summary: XSLTC fails on java extension functions using
                    NodeIterator args
           Product: XalanJ2
           Version: 2.5Dx
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Major
          Priority: Other
         Component: org.apache.xalan.xsltc
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [EMAIL PROTECTED]


My company has a collection of stylesheets (around 80 to 100) using Java 
extension functions, and we are currently using Xalan interpretive XSL 
transformation to render them. I'm currently trying to "port" them to work 
under XSLTC ... unfortunately there's enough differences that I have to use the 
word port. Most are insignificant (interpretive Xalan is more graceful about 
lack of unused templates than XSLTC), but there's one in particular that's a 
blocker.

The problem I'm about to explain works with no complaints on interpretive 
Xalan, but XSLTC won't compile the stylesheet.

We use an extension function "cleanForJS" (below) extensively:

<snip fromClass="jp.ne.sonet.mrkun.taglib.xsl.XSLFunctions">

  /**
   * Handles the formatting of text using the cleanForJS function
   * @param itrContent The field to be formatted
   * @return A string valid for javascript
   */
  public static String cleanForJS(org.w3c.dom.traversal.NodeIterator itrContent)
  {
    org.w3c.dom.Element domText = (org.w3c.dom.Element) itrContent.nextNode();
    if (domText == null)
      return "";
    else if (domText.getChildNodes().getLength() == 0)
      return "";
    else
    {
      String inputText = domText.getFirstChild().getNodeValue();
      return StringUtils.cleanForJS(inputText);
    }
  }

</snip>

The stylesheet drtemplate.xsl is:

<?xml version="1.0" encoding="Shift_JIS"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:mrkun="xalan://jp.ne.sonet.mrkun.taglib.xsl.XSLFunctions"
                extension-element-prefixes="mrkun"
                version="1.0">

  <xsl:output method="html" encoding="Shift_JIS"/>
  
  <xsl:template match="routerServlet">

    <html>
      <head>
        <title>Test</title>
      </head>
      <body>
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="userMessage">
    <xsl:if test="not(userMessage = '')">
      <script language="javascript">
        alert('<xsl:value-of select="mrkun:cleanForJS(.)"/>');
      </script>
    </xsl:if>
  </xsl:template>      

</xsl:stylesheet>

The command line compiler says (as does the TrAX version):

D:\>java -classpath C:\weblogic\myserver\serverclasses;D:\xsltc.jar 
org.apache.xalan.xsltc.cmdline.Compile drtemplate.xsl
Compiler error(s):
  Cannot convert argument/return type in call to 
method 'jp.ne.sonet.mrkun.taglib.xsl.XSLFunctions.cleanForJS(
node-type)'

I did some probing, and it seems that it's only functions with NodeIterator 
arguments that seem bothered by it.

Please let me know if you need any more information ... I'm going to have to 
decide in a day or two whether to use XSLTC, and this is currently a blocker. 
Other than this, it's fantastic - the speed improvements are blinding ... very 
impressive work.

Regards,

Rick Knowles
So-net M3

Reply via email to