You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by S Page <sp...@macromedia.com> on 2001/05/12 06:13:32 UTC

element-available('xalan:write') test fails in xsl:choose , work s in xsl:if

I'm trying to test for the availability of the xalan:write extension element.

element-available('xalan:write') works inside xsl:if, but the exact same test doesn't work inside an xsl:when inside xsl:choose.  Testing the availability of a standard xsl element works fine in both xsl:if and xsl:when.

Perhaps Xalan-J's namespace handling is different in an xsl:when.

Here's a really simple test XSL file:
------ CUT HERE ------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"    
    version="1.1">

<xsl:template match="/">
    <xsl:if test="element-available('xsl:attribute')">
        SUCCESSFUL IF TEST element-available('xsl:attribute')
    </xsl:if>

    <xsl:if test="element-available('xalan:write')"  
        xmlns:xalan="org.apache.xalan.xslt.extensions.Redirect"
        >
        SUCCESSFUL IF TEST element-available('xalan:write')
    </xsl:if>

    <xsl:choose>
    <xsl:when test="element-available('xsl:attribute')">
        SUCCESSFUL CHOOSE WHEN TEST element-available('xsl:attribute')
    </xsl:when>
    </xsl:choose>

    <xsl:choose>
    <xsl:when test="element-available('xalan:write')"  
        xmlns:xalan="org.apache.xalan.xslt.extensions.Redirect"
        >
        SUCCESSFUL CHOOSE WHEN TEST element-available('xalan:write')
    </xsl:when>
    </xsl:choose>
</xsl:template>

------ CUT HERE ------

If you save this as xalan_choose_bug.xsl and run
	% java org.apache.xalan.xslt.Process  -xsl xalan_choose_bug.xsl

you get
	<?xml version="1.0" encoding="UTF-8"?>
        SUCCESSFUL IF TEST element-available('xsl:attribute')
        SUCCESSFUL IF TEST element-available('xalan:write')
        SUCCESSFUL CHOOSE WHEN TEST element-available('xsl:attribute')

(the last test doesn't output).

If I turn on all its trace options, Xalan-J just confirms that the test fails.

% java org.apache.xalan.xslt.Process -tt -tg -ts -ttc  -xsl xalan_choose_bug.xsl 
Line #5, Column #25: template match='/' 
Line #6, Column #52: if
Line #6, Column #52: if, test='element-available('xsl:attribute')': true
Line #8, Column #12 -- #Text:     SUCCESSFUL IF TEST element-available('xsl:attribute')
STARTDOCUMENT
CHARACTERS: 
                SUCCESSFUL IF TEST element-available('xsl:attribute')
        
Line #12, Column #4: if
Line #12, Column #4: if, test='element-available('xalan:write')': true
Line #14, Column #12 -- #Text:     SUCCESSFUL IF TEST element-available('xalan:write')
CHARACTERS: 
                SUCCESSFUL IF TEST element-available('xalan:write')
        
Line #16, Column #14: choose
Line #17, Column #54: when, test='element-available('xsl:attribute')': true
Line #19, Column #14 -- #Text:     SUCCESSFUL CHOOSE WHEN TEST element-available('xsl:attribute')
CHARACTERS: 
                SUCCESSFUL CHOOSE WHEN TEST element-available('xsl:attribute')
        
Line #22, Column #14: choose
Line #25, Column #4: when, test='element-available('xalan:write')': false


(but this last "when" test looks the same as the previous "if" test).

I'm new around here, should I file a bug?

Thanks,
-- 
=S Page  a www.macromedia.com site engineer

  Big corporations are stripping you of your rights.
  http://www.toad.com/gnu/whatswrong.html


Re: element-available('xalan:write') test fails in xsl:choose , works in xsl:if

Posted by Gary L Peskin <ga...@firstech.com>.
This is the exact problem.  XalanJ's handling of the namespace in
xsl:when was incorrect.  It was using the namespaces from the xsl:choose
element and its parents rather than the xsl:when element itself.

I've uploaded a fix for this.  Please add your bug to bugzilla so that
it is documented and I will update your document with the current
resolution.

Thanks much for reporting this,
Gary

S Page wrote:
> 
> I'm trying to test for the availability of the xalan:write extension element.
> 
> element-available('xalan:write') works inside xsl:if, but the exact same test doesn't work inside an xsl:when inside xsl:choose.  Testing the availability of a standard xsl element works fine in both xsl:if and xsl:when.
> 
> Perhaps Xalan-J's namespace handling is different in an xsl:when.
> ...