Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2003, 04:59 AM
Registered User
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with Attributes

Hi chaps,

Can anyone help me? I have an XML file that describes a list of options in a menu, with each item I have a link to a web file e.g. <link>http://MyFile.htm</link>, I am using XSL to transform the file into a webpage and am trying to use the link of the item in a <a href="<xsl:value-of select="link"/>"> but the parser tells me I can't put <xsl:value-of select="Link"/> in an attribute, I've looked around on the web but am unable to find any examples of people doing the same!

Can someone tell me how it's done?

Cheers

Pete
 
Old July 4th, 2003, 06:16 AM
Registered User
 
Join Date: Jun 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

The parser won't let you pass the attribute as such because there is an xsl attribute tag that allows to do what you want to do. The syntax would be as such,

<a>
   <xsl:attribute value="href">
      <xsl:value-of select="link"/>
   </xsl:attribute>
</a>

The xsl:attribute tag takes the attribute parameter of the anchor tag as its value. Anything you place between beginning and end of the xsl:attribute tag will be considered as input to the value parameter. Finally, you have to close the anchor tag.

Hope this helps. Any questions just let me know.

Abdel
 
Old July 4th, 2003, 07:45 AM
Registered User
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks abdel, I tried this but it doesn't seem to work, I get a Attribute 'value' is invalid on 'xsl:attribute'. error, I've checked that I am returning something from the link element and I am - I'm returning //lsrv004 for example.

Any ideas?

Pete
 
Old July 4th, 2003, 08:17 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

The easiest thing is to use an "Attribute value template":
<a href="{link}">
OR use the full syntax:
<a>
   <xsl:attribute name="href">
      <xsl:value-of select="link"/>
   </xsl:attribute>
</a>
I suggest yopu download Msxml parser 4 which has an excellent help file packed with examples.


--

Joe
 
Old July 4th, 2003, 08:37 AM
Registered User
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cheers Joe, that worked a treat, I'll down load that file.

Thanks again, and thankyou Abdel

Pete
 
Old July 5th, 2003, 07:44 AM
Registered User
 
Join Date: Jun 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Sorry the code snippet I gave had an error ('value' should always be 'name')which joe has corrected with his entry. Glad you got working in the end.

Abdel





Similar Threads
Thread Thread Starter Forum Replies Last Post
restrictions on attributes kfir XML 2 May 30th, 2006 04:35 AM
Elements and attributes Morrislgn XSLT 1 June 20th, 2005 11:13 AM
How to get certain ADSI Attributes grassi3000 C# 0 August 31st, 2004 12:03 PM
How to get Attributes of a element? g_srihari9 XSLT 1 August 18th, 2003 07:11 AM
Problems with Attributes pj_bennett XSLT 1 July 8th, 2003 01:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.