Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > XSL and XML question with creating a hyperlink

XSL and XML question with creating a hyperlink
Thread Tools
Mac Elite
Join Date: Sep 2001
Location: MA, USA
Status: Offline
Reply With Quote
Jun 10, 2005, 07:07 PM
 
Ok, here is a sample of the code:

Code:
<?xml version="1.0" encoding="UTF-8" ?> <?xml-stylesheet type="text/xsl" href="allShared_style.xsl"?> <playlist ownerId="" type="playlist" id="" > <name></name> <track> <downloadURL mediaPolicy="4" id="23407425" fileSize="5704741" >media/23407425</downloadURL> <title>Learn To Fly</title> <duration>238</duration> <album>There Is Nothing Left to Lose</album> <artist>Foo Fighters</artist> <hostTarget></hostTarget> </track>
I need to make a table for testing purposes. The table is working except for one thing, creating a download link.

Code:
<!--Insert Rows--> <xsl:template match="track"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> <td><xsl:value-of select="duration"/></td> <td><xsl:value-of select="album"/></td> <td><xsl:value-of select="downloadURL/@mediaPolicy"/></td> <td><xsl:value-of select="downloadURL/@fileSize"/></td> <td><a href="{@downloadURL}"><xsl:value-of select="downloadURL"/></a></td> <td><xsl:value-of select="hostTarget"/></td> </tr> </xsl:template>
I can't figure out how to get the downloadURL to become the link. What I have right now creates a link to the xml file. I need it to link to media/content_number
AXP
ΔΣΦ
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Jun 10, 2005, 07:33 PM
 
I tend to use the more verbose form of XSLT myself. In that form, you'd do it like this:
Code:
<xsl:element name="a"> <xsl:attribute name="href"><xsl:value-of select="downloadURL"/></xsl:attribute> <xsl:value-of select="downloadURL"/> </xsl:element>
That said, I think you can do this in your shorter form as well. The result would be something like this:
Code:
<td><a href="<xsl:value-of select="downloadURL"/>"><xsl:value-of select="downloadURL"/></a></td>
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Mac Elite
Join Date: Sep 2001
Location: MA, USA
Status: Offline
Reply With Quote
Jun 10, 2005, 08:46 PM
 
I tried that on my PC at work, and it didn't work. On Safari, its just a white screen which I am guessing means an error also.

The reason this is annoying[Code Samples]:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="index_style.xsl"?> <playlist-index> <playlist title="jon2" href="/addresst" /> </playlist-index>
Code:
<!--Link Creation Template--> <xsl:template match="playlist"> <li><a href="{@href}"><xsl:value-of select="@title"/></a></li> </xsl:template>
That works fine, I just can't get the other one to work.
AXP
ΔΣΦ
     
Mac Elite
Join Date: Sep 2001
Location: MA, USA
Status: Offline
Reply With Quote
Jun 13, 2005, 07:59 AM
 
All i needed to do was take out "@" sign:

Code:
<td><a href="{downloadURL}"><xsl:value-of select="downloadURL"/></a></td>
AXP
ΔΣΦ
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:15 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2