Subject: Re: [xsl] Putting a param into <link /> From: Marco Guazzone <sguazt@xxxxxxxxxxx> Date: Wed, 12 Mar 2003 12:46:28 +0100 (CET) |
Hi, So you'd want to just bind the variable "project" (in the main xsl) with the param "project" (in the helper xsl) huh? You can't do it! In alternative you can replace the variable "project" with a parameter: [main xsl] <xsl:param name="project" select="/root/session/projectName"/> ... [helper xsl] <xsl:param name="project"/> Then you just pass the value of parameter "project" when you call the main xsl with your preferred processor. If the main xsl use $project only through the helper one, you can eliminate the declaration of $project from the main xsl and just passing its value with the processor. For example (I use the LibXSLT processor): > xsltproc --param project '"/root/session/AnotherProjectName"' main.xsl doc.xml XML (doc.xml): --- <?xml version="1.0"?> <doc/> --- MAIN XSL (main.xsl): --- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import href="helper.xsl"/> <!-- This declaration replace the declaration of variable "project" Remove this if $project is only used inside helper.xsl! --> <xsl:param name="project" select="/root/session/projectName"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet> --- HELPER XSL (helper.xsl) --- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="project" select="''"/> <xsl:template match="doc"> <link rel="stylesheet" type="text/css" href="/{$project}/css/styles.css" /> </xsl:template> </xsl:stylesheet> --- Regards, -------------------------------- Marco Guazzone Software Engineer Kerbero S.r.L. - Gruppo TC Viale Forlanini, 36 Garbagnate M.se (MI) 20024 - Italy mail: marco.guazzone@xxxxxxxxxxx www: http://www.kerbero.com Tel. +39 02 99514.247 Fax. +39 02 99514.399 -------------------------------- On Wed, 12 Mar 2003, Simon Kelly wrote: > [1]<snip> > > You want > > > > foo="{$project}" > > > > Cheers, > ...</snip> > > [2]<snip> > > Second, you have to surround the reference to $project inside the href > > attribute with "{...}"; i.e.: > > <link rel="stylesheet" type="text/css" href="/{$project}/css/styles.css" > /> > ...</snip> > > > Thanks Jarno[1] and Marco[2]. > > Unfortunately, it doesn't seem too work. The param is not going into an > <xsl:...> tag, but into a html tag. The variable is set in the main xsl > style sheet, and the actual <xsl:template ... /> is in an included helper > xsl stylesheet. (I think I'm right in saying that the param name needs to > match the variable name to do this!?!) > > So, > <xsl:variable name="project" select="/root/session/projectName" /> [in > main.xsl] > ....... > <xsl:param name="project" /> [in inc_main.xsl] > ....... > <link rel="stylesheet" type="text/css" href="/{$project}/css/styles.css" /> > [in inc_main.xsl] > > just gives > > <link rel="stylesheet" type="text/css" href="//css/styles.css" /> > > as the rendered output. > > Is there any way of using <xsl:text /> to insert this data?? > > Cheers > > Simon > > > > > Jarno - This Morn'Omina: One Eyed Man ... brilliant song!!! > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Putting a param into <lin, Simon Kelly | Thread | RE: [xsl] Putting a param into <lin, Jarno . Elovirta |
RE: [xsl] 2 XML source, Cams Ismael | Date | Re: [xsl] Answers to review questio, Jeni Tennison |
Month |