Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Simple question about XSL and XML [Thread Next] Re: Simple question about XSL and XMLTo: NULL Date: 6/7/2007 7:26:00 PM
roassaf@g... wrote:
> On Jun 6, 9:54 pm, "toudidel" <x...@neostrada.pl> wrote:
>> U¿ytkownik <roas...@gmail.com> napisa³ w wiadomoœcinews:1181152677.588992.118820@i......
>>
>>> <money>
>>> <money-site url="www.yahoo.com"> Yahoo finance </money-site>
>>> <money-site url="www.cnn.com"> CNN finance </money-site>
>>> </money>
>>> How can I retrieve the value of the url and put it inside the href
>> <xsl:apply-templates match="/money/money-site"/>
>> ...
>> <xsl:template match="money-site">
>> <a href="{@url}"><xsl:value-of select="."/></a>
>> </xsl:template>
>>
>> --
>> tdwww.paranoja.org
>
> Hi,
>
> Thanks for the quick answer.
> I have a follow up question:
>
> If I have a case where I don't get the URL only the name of the
> website and then I want to display it with no url.
> Is there any condition for me to check if the url exists (when it is
> in the form of the example above).
If you have money-site elements without a url attribute then this should do:
<xsl:template match="money-site[@url]">
<a href="{@url}"><xsl:value-of select="."/></a>
</xsl:template>
<xsl:template match="money-site[not(@url)]">
<span><xsl:value-of select="."/></span>
</xsl:template>
If those money-site elements have an empty url attribute then you could use
<xsl:template match="money-site[string(@url)]">
<a href="{@url}"><xsl:value-of select="."/></a>
</xsl:template>
<xsl:template match="money-site[not(string(@url))]">
<span><xsl:value-of select="."/></span>
</xsl:template>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
