Jump to content
  • Advertisement
Sign in to follow this  
Knytestorme

[web] href in xslt from xml file

This topic is 4866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Greetings all, I'm just trying to solve a problem here at work and I've never been able to work out how to do it while playing around previously so thought I'd check here :). Given an xml file such as
<Show>
        <Title>dgds</Title>
        <Description>dgxfdgbfxz</Description>
        <Duration>30</Duration>
        <Link>/data/Ant-46/2005/09/_Ant-46_20050920_100446.avi</Link>
        <Recorded>20/09/2005 10:04:46 AM</Recorded>
        <Uploaded>21/11/2005 9:50:40 AM</Uploaded>
</Show>

and an xslt of
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <html>
    <body>
    <!--
        This is an XSLT template file. Fill in this area with the
        XSL elements which will transform your XML to XHTML.
    -->

		<xsl:apply-templates select="//Channel" />
		
    </body>
    </html>
</xsl:template>

<xsl:template match="Channel">
	<h3>
		<u><xsl:value-of select="Name"/></u>
	</h3>
	<xsl:apply-templates select="Show" />	
</xsl:template>
<xsl:template match="Show">
	<xsl:apply-templates select="Title" />
	<hr />
	Recorded: <xsl:apply-templates select="Recorded" /><br />
	Duration: <xsl:apply-templates select="Duration" /> Minutes<br />
	<p />
	Description: <xsl:apply-templates select="Description" /><p />
</xsl:template>
<xsl:template match="*">
	<xsl:value-of select="." />
</xsl:template>	
</xsl:stylesheet> 

My question is, how would I go about using the linnk node as a href around the title node. I've tried various permutations of something like
<a href=<xsl:apply-templates select="link">><xsl:apply-templates select="Title"></a>

but as expected it doesn't work so any help would be most appreciated. I'm currently doing this using the xml object in asp 2.0 c# but if I can only do it using XPath or similar then I have no issues with changing if it's quick enough...damn deadlines :)

Share this post


Link to post
Share on other sites
Advertisement
Quote:
<a href=<xsl:apply-templates select="link">><xsl:apply-templates select="Title"></a>

That's not valid XML. Use the element and attribute elements in the XSLT namespace to create the anchor tag.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!