Using Xalan for XSL Transformation

  • Thread starter =?iso-8859-1?q?Eduardo_Y=E1=F1ez_Parareda?=
  • Start date
?

=?iso-8859-1?q?Eduardo_Y=E1=F1ez_Parareda?=

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?=

I forgot to mention that I'm using the last Xalan version, and JDK5.
 
J

Joe Kesselman

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.
 
J

Joe Kesselman

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top