Hi Aaron,
Here is a short stylesheet giving you your desired output:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="no" encoding="UTF-8"/>
<xsl:template match="/">
<html>
<head>
<title>Hyperlink Test Page</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="text">
<p>
<!-- looks for further child elements within <p>, text
is output -->
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="link">
<a href="{(_at_)url}">
<xsl:apply-templates/>
</a>
</xsl:template>
</xsl:stylesheet>
Output:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
<title>Hyperlink Test Page</title>
</head>
<body>
This is some welcome text
<a href="http://www.somthing.co.uk">XML Hyperlink</a>
</body>
</html>
Altough you can get the same output using an optimized version of your
<xsl:for-each> instructions,
working with <xsl:apply-templates/> is easier and makes your code more
maintainable.
HTH
wbr,
Roman
_______________________________________
Roman Huditsch
IT and Electronic Publishing
LexisNexis ARD Orac
Marxergasse 25
1030 Vienna
Austria
ph: +43-1-534 52-1514
f: +43-1-534 52-140
e-mail roman(_dot_)huditsch(_at_)lexisnexis(_dot_)at
www.lexisnexis.at
-----Ursprüngliche Nachricht-----
Von: Aaron Johnson [mailto:Aaron2(_dot_)Johnson(_at_)uwe(_dot_)ac(_dot_)uk]
Gesendet: Mittwoch, 26. Januar 2005 12:58
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: [Maybe spam] [xsl] Hyperlinks [newbie Q]
Hi...
I would like the text 'XML Hyperlink' to be a link on the
rendered html page.
I want it so that if you need to change the url, you change
it in the xml rather than in the xsl.
How do I get the xsl to make this a hyper link?
XML:
<welcome>
<text>This is some welcome text</text>
<link url="http://www.somthing.co.uk">XML
Hyperlink</link> </welcome>
XSL so far:
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="no" encoding="UTF-8"/>
<xsl:template match="/">
<html>
<xsl:for-each select="welcome/text">
<p><xsl:value-of select="."/></p>
</xsl:for-each>
<xsl:for-each select="welcome/link">
<p<xsl:value-of select="."/></p>
</xsl:for-each>
</html>
</xsl:template>
</xsl:stylesheet>
Does any one have any pointers to tutorials? Any help would
be appreciated thank you.
Aaron
This email has been independently scanned for viruses and any
virus software has been removed using McAfee anti-virus software
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--