RE: [xsl] Variable construction

Subject: RE: [xsl] Variable construction
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 21 Sep 2005 15:18:45 +0100
> I have a piece of text containing a variable. The variable is a url
> specified in an external document...

You mean your source document contains $helpUrl and you want to replace it
with the value of the variable $helpUrl defined in your stylesheet?

Sounds a reasonable thing to do - except that the scope of a variable name
is confined to certain parts of the stylesheet, and doesn't extend to the
source document. At run-time there is no way of getting the value of a
variable whose name you've just read from the source document.

You might as well use any symbolic name in the source document, for example
href="%%helpUrl%%", and in the stylesheet you will need some kind of lookup
mechanism of the form

<xsl:when test="@href='%%helpURL%%'">
  <xsl:attribute
name="href">http://info.uwe.ac.uk/myuwe/myMarks.asp</xsl:attribute>
</xsl:when>

But perhaps I've completely misunderstood what you are trying to do.

Michael Kay
http://www.saxonica.com/


> 
> The text...
> 
> .....If you have any queries, please contact your <a target="_blank"
> href="{$helpUrl}">Faculty Office</a> without delay....
> 
> How should I construct the variable so as to output the url? 
> Can I do it as
> xsl:text?
> 
> The variable...
> 
> <xsl:variable name="helpUrl">
>       <xsl:text>http://info.uwe.ac.uk/myuwe/myMarks.asp</xsl:text>
> </xsl:variable>
> 
> Thanks...
> 
> Aaron
> 
> ..................................................................
> 
> Aaron Johnson
> GUI / XSLT development
> Academic Technologies Group [ATG]
> University of the West of England
> 0117 3281051 [ext: 81051]
> atg.uwe.ac.uk/aaron
> 
> SECURITY POLICY:
> 
> Please note that ATG will only accept
> e-mail attachments in the following
> formats: 
> 
> .asp,.bin,.doc,.gif,.html,.jpg,.mdb,.png,
> .psd,.shtml,.sdf,.sit,.xls,.xml,.xsd,.xsl,.zip,
> 
> ..................................................................
> 
> This communication is intended solely
> for the use of the individual(s) to whom
> it is addressed. Any opinions presented
> are those of the author and do not
> necessarily represent the University of
> the West of England, Bristol.
> ..................................................................
> 
> 
> 
> This email has been independently scanned for viruses and any 
> virus software has been removed using McAfee anti-virus software

Current Thread