This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

How to retrieve value in xsl:value variable??


I'm new to XSL, and thought someone on the Net can give me some help on
this.

I have the following elements in my x.xml file. Some of the information
in the file will be extracted and used
in a text doc:

<PERIODIC_TABLE>
  <ATOM STATE="GAS">
    <NAME>Hydrogen</NAME>
    <SYMBOL>H</SYMBOL>
  </ATOM>
</PERIODIC_TABLE>

----------------------------------------------------------------------------------------------

Desired output: Information for: Hydrogen
----------------------------------------------------------------------------------------------

So I defined the following in my x.xsl file:

<xsl:template match="/"><xsl:apply-templates/></xsl:template>
<xsl:template match="ATOM">

<!-- define a varialbe -->
<xsl:variable name='atomname'>
<xsl:value-of select="NAME"/>
</xsl:variable>

<!-- print out some information -->
Information for: <xsl:value-of select='$atomname'/>
Name:             <xsl:value-of select='$atomname'/>
<!-- end of output -->

</xsl:template>
</xsl:stylesheet>
-----------------------------------------------------
The reson I defined a variable "atomname" is because I want to use it in
several places in my doc. However,
I would like to be able to retrieve the value using $atomname without
invoking <xsl:value> call, i.e. is
there a way that I can print my information in the following way in my
x.xsl file?

<!-- print out some information -->
Information for: '$atomname'
Name:              '$atomname'
<!-- end of output -->

This didn't work ($atomname is printed instead of the value stored in
the variable) when I tried to using to process my
files using a XSLT processor.

Thanks for any help/suggestion, etc. If possible, email reply preferred.



Lucie C. Chan <lcchan@lucent.com>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]