Using Xalan for XSL Transformation

Discussion in 'XML' started by =?iso-8859-1?q?Eduardo_Y=E1=F1ez_Parareda?=, Apr 12, 2007.

  1. Hello, I have to use xalan to transform some XML using XSL, but I have
    some problems
    within the XSLs, and Xalan doesn't give very good error messages. Is
    there any
    way to put Xalan on debug or trace mode or something else?, it's
    almost impossible to find the
    problems with those messages. i.e.:

    This is /xsl/template/list.xsl

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:Date="java.util.Date"
    xmlns:StringBuffer="java.lang.StringBuffer"
    xmlns:parser="es.bfc.xslt.Parser"
    exclude-result-prefixes="Date StringBuffer parser">

    <xsl:variable name="updateData" select="StringBuffer:new(' ')"/> <!--
    LINE 17 -->

    <!-- Some code -->

    <xsl:text disable-output-escaping="yes">&lt;script
    language="javascript"&gt;</xsl:text>
    function setSelectedSelectionCriteriaFields(){
    <xsl:value-of select="$updateData" disable-output-escaping="yes" /
    > <!-- LINE 327 -->

    }
    <xsl:text disable-output-escaping="yes">&lt;/script&gt;</xsl:text>

    </xsl:stylesheet>

    This is the error:
    file:///xsl/template/list.xsl; Line #17; Column #66;
    java.lang.IllegalArgumentException
    file:///xsl/template/list.xsl; Line #327; Column #72;
    java.lang.NullPointerException

    Why an empty string throws an IllegalArgumentException? WHY?!! :(
    =?iso-8859-1?q?Eduardo_Y=E1=F1ez_Parareda?=, Apr 12, 2007
    #1
    1. Advertising

  2. I forgot to mention that I'm using the last Xalan version, and JDK5.
    =?iso-8859-1?q?Eduardo_Y=E1=F1ez_Parareda?=, Apr 12, 2007
    #2
    1. Advertising

  3. It's extremely hard for a processor to give good error messages for
    errors in the use of extension functions, and that's what you seem to
    have here.

    When I have time I'll try to look at this in more detail... but mucking
    about with a StringBuffer is almost certainly the wrong solution.


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Apr 12, 2007
    #3
  4. After fixing some of the typos and omissions and blatent bad practices
    in the fragment you showed us (other than the use of extension code
    where it's probably not necessary and in a way that implies you're
    forgetting that XSLT doesn't guarantee execution order), it runs without
    errors in a reasonably recent version of Xalan executed under Java
    1.4.1. In fact, modifying the StringBuffer's initialization, I can
    confirm that it's being passed through and retrieved from successfully.

    Rebuilt all of Xerces and Xalan under Java 1.5, and ran the stylesheet
    under that... and it worked fine there too.

    No Trouble Found in Xalan. If you want help, you're going to have to
    give us enough information to let us replicate and diagnose the problem.


    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:Date="java.util.Date"
    xmlns:StringBuffer="java.lang.StringBuffer"
    xmlns:parser="es.bfc.xslt.Parser"
    exclude-result-prefixes="Date StringBuffer parser">

    <!-- Stateful extension functions are a BAD PRACTICE! -->
    <xsl:variable name="updateData" select="StringBuffer:new(' ')"/>

    <xsl:template match="/">
    <script language="javascript">
    function setSelectedSelectionCriteriaFields(){
    <xsl:value-of select="$updateData" disable-output-escaping="yes" />
    }
    </script>
    </xsl:template>

    </xsl:stylesheet>




    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Apr 13, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bastien

    XSL+XML=> HTML using xalan.

    bastien, May 25, 2004, in forum: XML
    Replies:
    0
    Views:
    482
    bastien
    May 25, 2004
  2. philips
    Replies:
    2
    Views:
    664
    philips
    Jul 17, 2004
  3. cvissy
    Replies:
    0
    Views:
    601
    cvissy
    Nov 16, 2004
  4. Replies:
    0
    Views:
    522
  5. Petterson Mikael
    Replies:
    3
    Views:
    972
    Martin Honnen
    May 23, 2007
Loading...

Share This Page