You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Reddy Anapalli Amarendra-E65017C <E6...@motorola.com> on 2006/02/17 21:19:35 UTC

xsltc throws exception when xsl:choose condition is evaluated

Hi All,

I have a template call as shown below to find out access_level. This
variable should be assigned to 3 after the template call returns. but
instead it throws runtime exception in translet while transformation. I
am unable understand the reason for failure.This works just fine with
interpretive processor.Please help. cut short version of xsl is
included.

Actual files which I am working are attached for transformations use.

<xsl:variable name="access_level"><xsl:call-template
namjava.lang.NullPointerException
        at
org.apache.xalan.xsltc.runtime.BasisLibrary.compare(BasisLibrary.java
:790)
        at translet.configRackNew.getAccessLevel()
        at translet.configRackNew.topLevel()
        at translet.configRackNew.transform()
        at
org.apache.xalan.xsltc.runtime.AbstractTranslet.transform(AbstractTra
nslet.java:593)
        at
org.apache.xalan.xsltc.trax.TransformerImpl.transform(TransformerImpl
.java:630)
        at
org.apache.xalan.xsltc.trax.TransformerImpl.transform(TransformerImpl
.java:301)
        at TraxTransform.doPost(TraxTransform.java:76)
        at
TraxTransform.main(TraxTransform.java:30)e="getAccessLevel"><xsl:with-pa
ram name="Port">TL1</xsl:with-param><xsl:with-param name="AccLevel"
select="'ACCESS_SUPER'"/></xsl:call-template></xsl:variable>

and the template getAccessLevel is written in specifics.xsl file which
is included in caller xsl.

<xsl:template name="getAccessLevel">
  <xsl:param name="AccLevel"/>
  <xsl:param name="Port"/>

  <xsl:choose>
    <xsl:when test="$Port = 'UI'"><xsl:value-of
select="$AccLevel"/></xsl:when>
    <xsl:otherwise>
      <xsl:choose>
        <xsl:when test="$AccLevel = $TL1_ADMIN">
          <xsl:value-of select="$ADMIN"/>
        </xsl:when>
        <xsl:when test="$AccLevel = $TL1_READ-WRITE">
          <xsl:value-of select="$READ-WRITE"/>
        </xsl:when>
        <xsl:when test="$AccLevel = $TL1_READ-ONLY">
          <xsl:value-of select="$READ-ONLY"/>
        </xsl:when>
        <xsl:when test="$AccLevel = $TL1_NONE">
          <xsl:value-of select="$NONE"/>
        </xsl:when>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template> 

your help would be highly appreciated.

Thanks in advance,

environment details:

#---- BEGIN writeEnvironmentReport($Revision: 1.29 $): Useful stuff
found: ----
version.DOM.draftlevel=2.0fd
java.class.path=C:\xalan-j_2_7_0\xalan.jar;"C:\Program
Files\Java\jdk1.5.0_06\jr
e\lib\rt.jar";C:\xalan-j_2_7_0\xercesImpl.jar;C:\xalan-j_2_7_0\xml-apis.
jar;C:\j
dom-1.0\build\jdom.jar
version.JAXP=1.1 or higher
java.ext.dirs=C:\Program Files\Java\jre1.5.0_06\lib\ext
version.xerces2=Xerces-J 2.7.1
version.xerces1=not-present
version.xalan2_2=Xalan Java 2.7.0
version.xalan1=not-present
version.ant=not-present
java.version=1.5.0_06
version.DOM=2.0
version.crimson=not-present
sun.boot.class.path=C:\Program
Files\Java\jre1.5.0_06\lib\rt.jar;C:\Program File
s\Java\jre1.5.0_06\lib\i18n.jar;C:\Program
Files\Java\jre1.5.0_06\lib\sunrsasign
.jar;C:\Program Files\Java\jre1.5.0_06\lib\jsse.jar;C:\Program
Files\Java\jre1.5
.0_06\lib\jce.jar;C:\Program
Files\Java\jre1.5.0_06\lib\charsets.jar;C:\Program
Files\Java\jre1.5.0_06\classes
#---- BEGIN Listing XML-related jars in: foundclasses.java.class.path
----
xalan.jar-path=C:\xalan-j_2_7_0\xalan.jar
xercesImpl.jar-apparent.version=xercesImpl.jar from Xerces-J-bin.2.7.1
xercesImpl.jar-path=C:\xalan-j_2_7_0\xercesImpl.jar
xml-apis.jar-apparent.version=xml-apis.jar from head branch of
xml-commons, tag:
 xml-commons-external_1_3_02
xml-apis.jar-path=C:\xalan-j_2_7_0\xml-apis.jar
dom.jar-path=C:\jdom-1.0\build\jdom.jar
dom.jar-apparent.version=dom.jar present-unknown-version
#----- END Listing XML-related jars in: foundclasses.java.class.path
-----
version.SAX=2.0
version.xalan2x=Xalan Java 2.7.0
#----- END writeEnvironmentReport: Useful properties found: -----
# YAHOO! Your environment seems to be OK.

 

Amar.

 


Re: xsltc throws exception when xsl:choose condition is evaluated

Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hi, Amar.

"Reddy Anapalli Amarendra-E65017C" <E6...@motorola.com> wrote on 
2006-02-17 03:19:35 PM:
> I have a template call as shown below to find out access_level.
> This variable should be assigned to 3 after the template call
> returns. but instead it throws runtime exception in translet
> while transformation. I am unable understand the reason for
> failure.This works just fine with interpretive processor.Please
> help. cut short version of xsl is included.
> Actual files which I am working are attached for
> transformations use.
> <xsl:variable name="access_level"><xsl:call-template namjava.lang.
> NullPointerException
>         at org.apache.xalan.xsltc.runtime.BasisLibrary.
> compare(BasisLibrary.java:790)
>         at translet.configRackNew.getAccessLevel()
>         at translet.configRackNew.topLevel()

     I don't think anybody ever responded to you.  This appears to be the 
same problem, with a different symptom described by Jira issue 
XALANJ-1742.[1]

     There is a reference to getAccessLevel inside the definition of the 
"access_level" global variable (in configRackNew.xsl), and getAccessLevel 
contains references to the global variables "TL1_ADMIN," "TL1_READ-WRITE," 
"TL1_READ-ONLY," and "TL1_NONE."  However, XSLTC is generating code that 
defines the access_level variable before the code that defines the values 
of those TL1_* variables.  The result is a NullPointerException for any of 
those undefined variables.

     The work-around is to modify your stylesheet to take into account 
dependencies between global variables.  If GV2 uses the value of GV1, 
place the definition of GV1 closer to the start of the document than GV2 
(or give it higher import precedence).

     I hope that helps.  If you feel that work-around is not acceptable, 
please feel free to add a comment to the Jira issue.

Thanks,

Henry
[1] http://issues.apache.org/jira/browse/XALANJ-1742
------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com