Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl:variable

Status
Not open for further replies.

kafmil

Technical User
Jul 15, 2002
71
0
0
AU
Does anyone know how to set a single variable using the <xsl:variable> element and then display that single variable without a for loop. I do not want an array of variables.

Thanks
 
consider the xml file below

------------------contacts.xml------------------------
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;contacts.xsl&quot;?>
<contacts>
<contact>
<first>John</first>
<last>Wayne</last>
<url></contact>
<contact>
<first>Tawani</first>
<last>Anyangwe</last>
<url></contact>
<contact>
<first>Francis</first>
<last>Drake</last>
<url></contact>
</contacts>

------------------contacts.xsl------------------------

<?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?>
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;<xsl:template match=&quot;/&quot;>
<ul><xsl:apply-templates/></ul>
</xsl:template>
<xsl:template match=&quot;contact&quot;>
<xsl:variable name=&quot;mycontact&quot;>
<xsl:value-of select=&quot;concat(first,' ',last)&quot;/>
</xsl:variable>
<li><a href=&quot;{url}&quot; style=&quot;font-family:verdana;font-size:8pt;&quot;>
<xsl:value-of select=&quot;$mycontact&quot;/>
</a></li>
</xsl:template>
</xsl:stylesheet>

________________________________________________________

If you have any questions, contact me or go to
and click on XMLRepublic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top