Register  Login       Search  
Forum  
 
  
 
Forum  Forum     
 
SearchForum Home
  XML Lab Products  nxslt  Passing paramet...
 Passing parameters (nsxlt2)
 
stefan
2 posts
www.oxygenxml.com
Joined
12/7/2005

Passing parameters (nsxlt2)
Posted: 07 Dec 05 2:10 AM (Romania)

For example consider the following stylesheet (named it withParam.xsl)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output encoding="UTF-8"/>
    <xsl:param name="param" select="'defaultValue'"/>
    <xsl:template match="/">
        <r>
            <xsl:value-of select="$param"/>
        </r>
    </xsl:template>
</xsl:stylesheet>

Running the following command:
nxslt2.exe withParams.xsl -xs param="another Value"
The result is:
<?xml version="1.0" encoding="IBM437"?><r>defaultValue</r>
Problems:
a) passing parameters seems not to work.
b) I get IBM437 instead of UTF-8 as encoding for the output document.

I'm using
.NET 2.0 XSLT command line utility, version 2.0 build 2165
(c) 2004-2005 Oleg Tkachenko, http://www.xmllab.net
Running under .NET 2.0.50727.42
olegt
85 posts
www.xmllab.net
Joined
2/25/2005

Re: Passing parameters (nsxlt2)
Posted: 07 Dec 05 4:33 AM (Israel)

1. Yeah,  my fault. Silly mistake, I'll upload fixed version in a minute.

2. You get 437 encoding because you output to the console. In this case nxslt outputs using console's encoding otherwise you can get unreadable result.  When outputting to a file (-o res.xml) you should get proper encoding.

That was actually done quite recently per a request from a user. Do you think it's wrong?


Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net | http://blog.tkachenko.com
stefan
2 posts
www.oxygenxml.com
Joined
12/7/2005

Re: Passing parameters (nsxlt2)
Posted: 07 Dec 05 10:22 AM (Romania)
Hi Oleg,

Yes, I think that is wrong. A better approach will be to allow the user to overwrite in the command line the serialization parameters, this is for instance how Saxon handles this. If I want to output with Saxon as ASCII the result of a transformation and ignore the encoding specified in the stylesheet I run:
java -jar saxon8.jar sampl.xml sample.xsl !encoding=ASCII

Best Regards,
Stefan

olegt
85 posts
www.xmllab.net
Joined
2/25/2005

Re: Passing parameters (nsxlt2)
Posted: 11 Dec 05 2:33 AM (Israel)

Well, overriding output serialization properties is an interesting idea and that's pretty much doable.

While I'm not sure about outputting to console. The idea was that when a user outputs to the console, she wnats to see the results and so encoding should be adjusted for proper viewing. Perhaps I should introduce another command line option for encoding and if it's specified use it for outputting to a file or console.


Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net | http://blog.tkachenko.com
  XML Lab Products  nxslt  Passing paramet...
Forum Home  Search