You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Brian S Krug (JIRA)" <xa...@xml.apache.org> on 2005/07/18 17:36:15 UTC

[jira] Created: (XALANJ-2173) XSLTC outputs current node when extension function returns null

XSLTC outputs current node when extension function returns null
---------------------------------------------------------------

         Key: XALANJ-2173
         URL: http://issues.apache.org/jira/browse/XALANJ-2173
     Project: XalanJ2
        Type: Bug
  Components: XSLTC  
    Versions: 2.6    
 Environment: java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode)

Microsoft Windows XP [Version 5.1.2600]
    Reporter: Brian S Krug
    Priority: Minor


The xsltc transformer factory (org.apache.xalan.xsltc.trax.TransformerFactoryImpl) incorrect handles a null from an extension function. Instead of outputting nothing, it outputs the string value of the current node of the source document. The interpretive transformer factory (org.apache.xalan.processor.TransformerFactoryImpl) does handle this correctly. See code below:
package test;

import java.io.InputStream;
import java.io.StringBufferInputStream;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

/**
 * @author bkrug
 *
 */
public class Test {
    private static final String xslText =
        "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" " +
                "xmlns:system=\"xalan://test.Test\" version=\"1.0\">" +
            "<xsl:template match=\"/\">" +
                "<xsl:for-each select=\"symbols/*\">" +
                    "The following should be blank: '<xsl:value-of select=\"system:giveNull()\"/>'.\n" +
                "</xsl:for-each>" +
            "</xsl:template>" +
        "</xsl:stylesheet>";
    public static void main(String[] args) throws Throwable {
        testNull("org.apache.xalan.processor.TransformerFactoryImpl");
        testNull("org.apache.xalan.xsltc.trax.TransformerFactoryImpl");
    }
    
    public static void testNull(String transformerFactoryClass) throws Throwable {
        System.setProperty("javax.xml.transform.TransformerFactory", transformerFactoryClass);
        String xml = "<symbols><letter>A</letter><letter>B</letter><number>1</number><number>2</number><letter>C</letter><letter>D</letter><number>3</number><letter>E</letter></symbols>";
        InputStream xsl = new StringBufferInputStream(xslText);
        TransformerFactory tf = TransformerFactory.newInstance();
        System.out.println("*** Running a test using TransformerFactory " + tf.getClass().getName());
        Transformer t = tf.newTransformer(new StreamSource(xsl));
        t.transform(new StreamSource(new StringBufferInputStream(xml)), new StreamResult(System.out));
        System.out.println();
        System.out.println("*** Done running this test");
        System.out.println();
    }
    
    public static Object giveNull() {
        return null;
    }
}

----------------------------------------------------------------------------------------------------- END OF CODE
To fix this, change org.apache.xalan.xsltc.runtime.BasisLibrary class at line 152 in method stringF(Object obj, int node, DOM dom) from 
return stringF(node, dom);
to
return "";





-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org