Subject: Re: [xsl] Variable construction: Afterthought... From: Jon Gorman <jonathan.gorman@xxxxxxxxx> Date: Wed, 21 Sep 2005 10:13:21 -0500 |
On 9/21/05, Aaron Johnson <Aaron2.Johnson@xxxxxxxxx> wrote: > > There is an existing document which I cannot change. In the document there > is a line of code... > > .....If you have any queries, please contact your <a target="_blank" > href="{$helpUrl}">Faculty Office</a> without delay.... > > ...which outputs a line of text with a url in it. > > I understand that the {$helpUrl} is a variable. > > The document that contains this variable, another .xsl, can be changed and > is as follows: > > <xsl:param name="helpFac"/> > <xsl:variable name="helpUrl"> > <xsl:choose> > <xsl:when test="$helpFac != > ''">http://info.uwe.ac.uk/myuwe/targettedHelp/default.asp?helpArea=<xsl:valu > e-of select="$helpFac"/></xsl:when> > > <xsl:otherwise>http://info.uwe.ac.uk/myuwe/targettedHelp/default.asp</xsl:ot > herwise> > </xsl:choose> > </xsl:variable> > > I want to get rid of the "helpFac" parameter as well as the choose statement > and replace the whole thing with a single url. Aaaahh, that makes a bit more sense. Do you really need to? It allows for templates calling that one to "override" the default. But if you really always want it to be one url you're on the right track. The stuff about external documents and the like is just a red herring. > ...so I thought that > > <xsl:variable name="helpUrl" > select="http://info.uwe.ac.uk/myuwe/myMarks.asp"/> > > ...would suffice. You just need quotation marks since it's not a path location but a string. > I can't test it because I don't have any xml to run > against it....sounds stupid I know but I'm still fairly new to xsl...I'm > trying to think logically. To create a test case here you don't need much. Create an xml file called foo.xml with <root>foo</root>. That should be more than enough to make most xml parsers happy. Then you can test it against a stylesheet like <xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:variable name="url" select="'http://www.url.com'" /> <xsl:template match="/"> <a href="{$url}">Test</a> </xsl:template> </xsl:stylesheet> with your favorite XSLT processor. If you're a newbie I highly highly recommend downloading an XSLT processor and playing around with running scripts by hand before trying to use the browser transformations. Jon Gorman
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Variable construction: Af, Aaron Johnson | Thread | Re: [xsl] Variable construction: Af, David Carlisle |
Re: [xsl] Strict sequential identit, Evan Lenz | Date | Re: [xsl] Variable construction: Af, David Carlisle |
Month |