Re: [xsl] XSL + Java extensions + Xalan + banging my head against the wall

Subject: Re: [xsl] XSL + Java extensions + Xalan + banging my head against the wall
From: James Melton <james.melton@xxxxxxxxxxx>
Date: Tue, 03 Jul 2001 16:33:29 -0400
The specific error might help. I think from looking at your code that
the method, setIndent(), should be static. 

Did you consider that you are doing a lot of String construction?
Instead you could try:

  public static String setIndent(int indent)
  {
    char[] indents = new char[indent];
    java.util.Arrays.fill(indents, " "); // use for loop if ver < 1.2
    return new String(indents);
  }

Mattio Valentino wrote:
> 
> Hi all.  I'm having some trouble with Java extensions.  I've been through
> the xml.apache.org documentation with no luck.
> 
> I'm using: Resin, Xerces/Xalan, and JSP to serve up the XML/XSL.
> 
> I'm doing something really silly wrong here, but I can't figure it out.
> Resin keeps telling me that it can't find the class file, so my guess is
> that it's a syntax error/omission on my part.
> 
> Here's what I'm doing:
> 
> <?xml version="1.0"?>
> <xsl:stylesheet
>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>         version="1.0"
>         xmlns:java="http://xml.apache.org/xslt/java";
>         exclude-result-prefixes="java">
> .
> .[all working stuff]
> .
> <xsl:template match="/">
>         <html>
>         <head>
>         <title>
> </xsl:template>
> .
> .[all working stuff]
> .
> <xsl:template match="poetry-line">
>         <div class="poetry-line">
>         <xsl:if test="@indent">
>         <!--2nd attempt-->
>         <xsl:param name="indentValue" select="@indent" /><b><xsl:value-of
> select="$indentValue" /></b>
>         <xsl:variable name="returnValue"
> select="java:testExtensions.setIndent($indentValue)" />
>         <b><xsl:value-of select="$returnValue" /></b>
> 
>         <!--1st attempt-->
>         <xsl:param name="indentValue" select="@indent" />
>         <b><xsl:value-of select="java:testExtensions.setIndent($indentValue)"
> /></b>
>         </xsl:if>
>         <xsl:apply-templates /></div>
> </xsl:template>
> 
> This is testExtensions.java, which has been compiled...
> 
> import java.util.*;
> import java.io.*;
> import java.lang.*;
> 
> public class testExtensions
> {
> 
>         public String setIndent(int indent)     {
>                         String indents="";
>                         for (int x=1; x<=indent; ++x) {
>                                 indents = indents + " ";
>                         }
> 
>         return indents;
>         }
> 
> }
> 
> Any help/advice/direction would be greatly appreciated!
> 
> Mattio
> xmlhack@xxxxxxxxxxx
> 
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 

____________________________________________________________
James Melton                 CyLogix
609.750.5190                 609.750.5100
james.melton@xxxxxxxxxxx     www.cylogix.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread