This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Passing parameters to xsl-stylesheet
- From: ben <ben at pulsesoftware dot co dot uk>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 31 Jan 2002 14:58:02 -0000
- Subject: RE: [xsl] Passing parameters to xsl-stylesheet
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Raguld,
Try something like this ...
ASP fragment;
Dim oXSL,oXML,sXML,template,processor
Set oXSL = Server.Createobject("MSXML2.FreeThreadedDOMDocument30")
oXSL.async = False
oXSL.validateOnParse = True
oXSL.Load (pstrStyleXML)
Set oXML = Server.Createobject("MSXML2.DOMDocument")
oXML.async = False
sXML = "<YOURXML><PERSON fname="John" lname="Smith"></PERSON><PERSON
fname="Bob" lname="Jones"></PERSON></YOURXML>"
oXML.LoadXML sXML
Dim template, processor
Set template = Server.Createobject(MSXML2.XSLTemplate30)
Set template.stylesheet = oXSL
Set processor = template.createProcessor
processor.input = oXML
processor.addParameter "myparam", "fname"
processor.Transform
Response.Write processor.output
Response.End
End ASP fragment.
XSL Fragement;
<xsl:stylesheet ....>
<xsl:param name="myparam"/>
<xsl:template match="/">
<xsl:apply-templates select="YOURXML">
</xsl:template>
<xsl:template match="YOURXML">
<xsl:for-each select="PERSON">
<xsl:sort select="@*[name() = $myparam]"/>
<td>
<xsl:value-of
select="concat(@fname,',',@lname)</xsl:value-of>
</td>
<xsl:for-each>
</xsl:template>
...
...
</xsl:stylesheet>
This is using server side VBScript in your ASP file.
Cheers,
Ben
-----Original Message-----
From: Ragulf Pickaxe [mailto:jawxml@hotmail.com]
Sent: 31 January 2002 14:04
To: xsl-list@lists.mulberrytech.com
Subject: [xsl] Passing parameters to xsl-stylesheet
Hello all,
What is the exact syntax of passing an argument (parameter) from an asp-page
to an xsl-stylesheet and what is the syntax for recieving the parameter in
the stylesheet?
I have a stylesheet that sorts an xml-file by various methods and want the
user to be able to choose which method to sort by.
Sorry, I know this is a real newbee question, and I have seen answers for it
before, but I can't find the answer in the archive and Michael Kay only
describe the passing in general terms that I can find (p. 284 in second
edition).
Sincerly
Raguld Pickaxe :)
_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________
===========================================================
Pulse Software Systems Limited.
Pulse House, 5 & 7 Gravel Hill, Leatherhead, Surrey. KT22 7HG
Tel: (01372) 220600 Fax: (01372) 362476
Web: http://www.pulsesoftware.co.uk
This e-mail (and any attachments) may contain confidential or privileged information. If you are not the intended recipient
or you receive this message in error please notify us immediately and delete the e-mail. Should this be the case then you are notified that any dissemination, distribution, or copying of this communication and its attachments is strictly prohibited.
This message has been checked for all known viruses by the
Message Labs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp
Neither Pulse Software Systems nor the sender accepts any liability or
responsibility for viruses or for any damage you may sustain. You should perform your own virus checks before opening any attachments.
===========================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list