Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT 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
  #1 (permalink)  
Old May 5th, 2005, 11:03 AM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default hyperlinks in XSLT, please help.

I'm soo frustrated because I can't get this to render properly. I'm new to this so any help would be greatly appreciated. Here is my xml:

<sitename xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Documents and Settings\mellan\Desktop\X-Excersize\content.xsd">

<bodycopy>
        <header>
    This is the header
    </header>
        <paragraph>
This is just another test paragrast another test paragrast another test paragrast another test paragrast another test paragrast <links><link name="Link text" url="http://www.url.com"/></links>
another test asdasdfasdfparagrast another test paragraph
</paragraph>
</bodycopy>

</sitename>

Here is my XSL where I'm trying to get this link to show in the actual paragraph (as structured above):

    <xsl:template match="bodycopy">
        <h1>
            <xsl:value-of select="header"/>
        </h1>
        <xsl:for-each select="paragraph">
                    <xsl:for-each select="links/link">
                        <a>
                            <xsl:attribute name="href">{@url}</xsl:attribute>
                            <xsl:value-of select="@url"/><p/>
                        </a>
            </xsl:for-each>
            <xsl:value-of select="text()"/>
            <p/>
        </xsl:for-each>
    </xsl:template>



As you can see I tried nesting it but I'm certain this is a horrible way to do this. Can anyhow give me some direction?

Thanks so much,
-m



  #2 (permalink)  
Old May 6th, 2005, 03:06 AM
Authorized User
 
Join Date: Jul 2004
Location: Oxford, , United Kingdom.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try something like this:

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

    <xsl:template match="bodycopy">
    <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="header">
        <h1>
            <xsl:apply-templates />
        </h1>
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="paragraph">
        <p><xsl:apply-templates /></p>
    </xsl:template>

    <xsl:template match="link">
        <a href="{@url}"><xsl:value-of select="@name" /></a>
    </xsl:template>

</xsl:stylesheet>



Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT to get hyperlinks in output ashv XSLT 2 December 7th, 2008 06:14 AM
Hyperlinks stephens1982 HTML Code Clinic 1 August 29th, 2005 12:13 AM
Hyperlinks bahachin Excel VBA 2 February 13th, 2005 04:50 AM
hyperlinks problem sbhandar Classic ASP Basics 2 September 2nd, 2004 07:18 PM
hyperlinks sbhandar Classic ASP Basics 4 August 19th, 2004 09:17 AM





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