Hi,

thank you :handshake:. Now it works fine with the latest version of xalan.
The confusing thing was that it was working with the java provided
xalan-version (e.g. with the Systemproperty set to the com.sun. ...
package).

It was a hard and long day  ;))  .....

Dirk




Kevin Cormier-2 wrote:
> 
> Hi Dirk,
> 
> You can only set top-level parameters through this interface.  If you move 
> your xsl:params above the xsl:template, it should work.
> 
> Kevin Cormier
> Software Developer, XSLT Development
> IBM Toronto Lab, D1-435
> E-mail:  [EMAIL PROTECTED]
> 
> 
> 
> From:
> neander <[EMAIL PROTECTED]>
> To:
> xalan-j-users@xml.apache.org
> Date:
> 11/20/2007 06:14 AM
> Subject:
> Transformer.setParameter does not work with 2.7.0
> 
> 
> 
> 
> Hi, I hope it is an easy one ...
> 
> I try to pass a parameter to a xslt-transformation by using the
> setParameter-method of the javax.xml.transform.Transformer class.
> In my project i enhanced the classpath with the latest xalan (2.7.0) and
> xerces (2.9.0) versions.
> 
> My Testclass:
> 
> public class Test
> {
>   public static void main(String[] args) throws Exception
>   {
>     System.out.println("internal Xalan-Version: " +
> com.sun.org.apache.xalan.internal.Version.getVersion());
>     System.out.println("external Xalan-Version: " +
> org.apache.xalan.Version.getVersion());
>     System.out.println("internal Xerces-Version: " +
> com.sun.org.apache.xerces.internal.impl.Version.getVersion());
>     System.out.println("external Xerces-Version: " +
> org.apache.xerces.impl.Version.getVersion());
> 
>     TransformerFactory transformerFactory =
> TransformerFactory.newInstance();
>     System.out.println("Factory: " + transformerFactory);
> 
>     URIResolver resolver = new URIResolver()
>     {
> 
>       public Source resolve(String href, String base) throws
> TransformerException
>       {
>         return new StreamSource(Test.class.getResourceAsStream("/" + 
> href));
>       }
> 
>     };
>     if (resolver != null)
>     {
>       transformerFactory.setURIResolver(resolver);
>     }
>     String xsltTemplate = "Template.xslt";
>     InputStream resourceAsStream =
> Test.class.getResourceAsStream(xsltTemplate);
>     Templates template = transformerFactory.newTemplates(new
> StreamSource(resourceAsStream));
>     System.out.println("Templates: " + template);
> 
>     Transformer transformer = template.newTransformer();
>     transformer.setParameter("hans", "franz");
>     transformer.setParameter("kurt", Boolean.TRUE);
>     transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
>     transformer.setOutputProperty(OutputKeys.METHOD, Method.HTML);
>     System.out.println("Transformer: " + transformer);
> 
>  
>     StringWriter writer = new StringWriter();
>     Result outputTarget = new StreamResult(writer);
>     StringReader reader = new StringReader("<?xml version=\"1.0\"
> encoding=\"ISO-8859-1\"?><Kurzprofil></Kurzprofil>");
>     transformer.transform(new StreamSource(reader), outputTarget);
> 
>     System.out.println(writer);
>   }
> 
> }
> 
> 
> My XSLT-File (Template.xslt): 
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet version="2.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>   <xsl:output method="html" version="1.0" encoding="ISO-8859-1"
>     omit-xml-declaration="yes" standalone="yes" indent="yes" />
> 
> 
>   <xsl:template match="/Kurzprofil">
>     <xsl:param name="hans" />
>     <xsl:param name="kurt" />
> 
>     <html>
>       <body>
>            <h1>Param Hans:<xsl:value-of select="$hans"/>"</h1>
>            <h1>Param Kurt:<xsl:value-of select="$kurt"/>"</h1>
>            <xsl:if test="$hans = 'franz'"><strong>Gotcha
> Hans!</strong></xsl:if><br/>
>            <xsl:if test="$kurt = 'true'"><strong>Gotcha
> Kurt!</strong></xsl:if>
>       </body>
>     </html>
>   </xsl:template>
> </xsl:stylesheet>
> 
> 
> When i run the Test-Application I get the following output: 
> 
> internal Xalan-Version: Xalan Java 2.6.0
> external Xalan-Version: Xalan Java 2.7.0
> internal Xerces-Version: Xerces-J 2.6.2
> external Xerces-Version: Xerces-J 2.9.0
> Factory: [EMAIL PROTECTED]
> Templates: [EMAIL PROTECTED]
> Transformer: [EMAIL PROTECTED]
> <html>
> <body>
> <h1>Param Hans:"</h1>
> <h1>Param Kurt:"</h1>
> <br>
> </body>
> </html>
> 
> 
> Obviously I didn't get the parameter-values and because I get
> org.apache.xalan.*-classes for the processing i am using the 2.7.0 Xalan
> Version.
> When I'm using the interal (JDK 1.5_04 provided Xalan/Xerces-Version) by
> adding the following System-Property 
> 
> System.setProperty(TransformerFactory.class.getName(),
> "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
> 
> I get the following output:
> 
> internal Xalan-Version: Xalan Java 2.6.0
> external Xalan-Version: Xalan Java 2.7.0
> internal Xerces-Version: Xerces-J 2.6.2
> external Xerces-Version: Xerces-J 2.9.0
> Factory:
> [EMAIL PROTECTED]
> Templates: 
> [EMAIL PROTECTED]
> Transformer:
> [EMAIL PROTECTED]
> <html>
> <body>
> <h1>Param Hans:franz"</h1>
> <h1>Param Kurt:true"</h1>
> <strong>Gotcha Hans!</strong>
> <br>
> <strong>Gotcha Kurt!</strong>
> </body>
> </html>
> 
> 
> This means that I'm now using the JDK 1.5_04 provided Versions 2.6 of 
> Xalan
> and Xerces and that everything is working fine.
> 
> Does anybody know what the problem with the actual Xalan Version 2.7.0 is?
> Did I miss something??
> 
> Best regards
> 
> Dirk 
> 
> 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Transformer.setParameter-does-not-work-with-2.7.0-tf4842797.html#a13854910
> 
> Sent from the Xalan - J - Users mailing list archive at Nabble.com.
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Transformer.setParameter-does-not-work-with-2.7.0-tf4842797.html#a13857689
Sent from the Xalan - J - Users mailing list archive at Nabble.com.

Reply via email to