 |
 |
XSL and XML question with creating a hyperlink
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: MA, USA
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
All i needed to do was take out "@" sign:
Code:
<td><a href="{downloadURL}"><xsl:value-of select="downloadURL"/></a></td>
|
|
AXP
ΔΣΦ
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |