[XML-SIG] Re: XML-SIG Digest, Vol 16, Issue 18
Norm Samuelson
nhs at llnl.gov
Mon Aug 16 17:48:05 CEST 2004
At 03:00 AM 8/14/2004, you wrote:
>Date: Fri, 13 Aug 2004 21:49:20 -0400
>From: Matt Price <matt.price at utoronto.ca>
>Subject: [XML-SIG] xslt/parameters
>To: python xml SIG <xml-sig at python.org>
>Message-ID: <20040814014920.GA10691 at utoronto.ca>
>Content-Type: text/plain; charset=us-ascii
>
>Can someone out there tell me how I pass a parameter value to an xsl
>stylesheet in python? Right now I have the following couple lines of
>code, more or less stolen from somewhere since I'm still pretty much at
>sea with xml:
>
> styledoc = libxml2.parseFile(xsl)
> style = libxslt.parseStylesheetDoc(styledoc)
> doc = libxml2.parseDoc(risxSet)
> result = style.applyStylesheet(doc, None)
> htmlString = style.saveResultToString(result)
>
>xsl is of course a variable which references a stylesheet. The
>stylesheet has a parameter setting like this:
>
><xsl: param
>name="mainTarget">http://localhost/refdb-client/index.py</xsl:param>
>
>I'd like to pass the parameter to the stylesheet in the above code.
>Can this be done in a straightforward way? I get the impression I
>should use the class libxslt.xpathParserContext(), but I really don't
>understand how it's supposed to work! I much appreciate any pointers.
>thanks,
>
>matt
I have one xsl stylesheet that uses a param. I use the stand-alone xalan
xslt processor. On the command line that starts xalan, I pass a number of
arguments (input file name, output file name, stylesheet name, etc) also
including the following three tokens:
-param targetCode ale3d
The first of those signals that I'm setting a param, the second is the name
of the param (as in the <xsl:param ...> tag, and the third is the value to
replace the default value given in the text under that tag.
Of course, if you are not using a stand-alone version you will need to find
a way to pass the params, but if you follow the logic of the stand-alone
version it should become obvious how to do it.
- Norm -
Norman H. Samuelson nhs at llnl.gov
Lawrence Livermore National Lab 925-422-0661
P.O. Box 808, L-98
Livermore, CA 94551
More information about the XML-SIG
mailing list