You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2001/03/09 16:53:24 UTC
[Bug 914] New - Parameters set with setParameter are accessible even without xsl:param
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=914
*** shadow/914 Fri Mar 9 07:53:23 2001
--- shadow/914.tmp.4007 Fri Mar 9 07:53:24 2001
***************
*** 0 ****
--- 1,71 ----
+ +============================================================================+
+ | Parameters set with setParameter are accessible even without xsl:param |
+ +----------------------------------------------------------------------------+
+ | Bug #: 914 Product: XalanJ2 |
+ | Status: NEW Version: 2.0.0 |
+ | Resolution: Platform: All |
+ | Severity: Normal OS/Version: Other |
+ | Priority: Medium Component: org.apache.xalan.transf |
+ +----------------------------------------------------------------------------+
+ | Assigned To: garyp@firstech.com |
+ | Reported By: garyp@firstech.com |
+ +----------------------------------------------------------------------------+
+ | URL: |
+ +============================================================================+
+ | DESCRIPTION |
+ Reported by Alex Roytman <ro...@peacetech.com>
+
+ I noticed that if we do myTransformer.setParameter(name, value) this parameter
+ is accessible by both <xsl:value-of> and XPathContext.getVariable()
+ even though it was not declared in the stylesheet - no errors/warnings raised
+
+ Sample java program:
+ import javax.xml.transform.TransformerFactory;
+ import javax.xml.transform.Transformer;
+ import org.apache.xalan.transformer.TransformerImpl;
+ import javax.xml.transform.stream.StreamSource;
+ import javax.xml.transform.stream.StreamResult;
+ import java.io.FileOutputStream;
+ import javax.xml.transform.TransformerConfigurationException;
+ import javax.xml.transform.TransformerException;
+ import org.apache.xml.utils.QName;
+ import java.io.IOException;
+
+ public class XalanTest1 {
+
+ public static void main(String[] argv)
+ throws TransformerConfigurationException, TransformerException, IOException
+ {
+
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+
+ Transformer transformer = tFactory.newTransformer(new StreamSource
+ ("foo.xsl"));
+
+ transformer.setParameter("myParam", "myParamValue");
+
+ transformer.transform(new StreamSource("foo.xml"), new StreamResult
+ (System.err));
+
+ QName varName = new QName("myParam");
+
+ System.err.println("getVariable = " + ((TransformerImpl)
+ transformer).getXPathContext().getVariable(varName));
+
+ }
+ }
+
+ XSL:
+ <?xml version="1.0"?>
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+
+ <xsl:template match="doc">
+ <out>myParam = <xsl:value-of select="$myParam"/></out>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+ XML:
+ <?xml version="1.0"?>
+ <doc>Hello</doc>