J
jjjlda
I am a bit of a novice and am running into trouble when trying to
create the xsl file to format my xml document. My xml document is of
the form:
<articles>
<publication>
<title>Title</title>
<filename>/dir/filename.txt</filename>
<authors>Author</authors>
<source>Source</source><date>Date</date>
</publication>
<articles>
I want the data to be formatted as follows at the end:
<table>
<tr><td><a href="/dir/filename.txt">Title</a></td></tr>
<tr><td>Author</td></tr>
<tr><td>Source</td></tr>
<tr><td>Date</td></tr>
</table>
I have come up with the following xsl file, but I cannot get the href
to work because it requires me to nest tags. I realzie the formatting
is a bit different, but this should be irrelevant.
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="articles">
<html><head><title><xsl:text>Reference</xsl:text></title></head>
<body>
<h1><xsl:text>Articles</xsl:text></h1>
<table border="0" cellpadding="2" cellspacing="2">
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="publication">
<tr>
<td><b><a href="child::filename"><xsl:value-of
select="title"/></a></b></td>
</tr>
<tr>
<td><xsl:value-of select="authors"/></td>
</tr>
<tr>
<td><xsl:value-of select="source"/><xsl:text>,
</xsl:text><xsl:value-of select="date"/></td>
</tr>
<tr>
<td colspan="3"><br></br></td>
</tr>
</xsl:template>
</xsl:stylesheet>
Can someone please help a novice out?
Thanks!
create the xsl file to format my xml document. My xml document is of
the form:
<articles>
<publication>
<title>Title</title>
<filename>/dir/filename.txt</filename>
<authors>Author</authors>
<source>Source</source><date>Date</date>
</publication>
<articles>
I want the data to be formatted as follows at the end:
<table>
<tr><td><a href="/dir/filename.txt">Title</a></td></tr>
<tr><td>Author</td></tr>
<tr><td>Source</td></tr>
<tr><td>Date</td></tr>
</table>
I have come up with the following xsl file, but I cannot get the href
to work because it requires me to nest tags. I realzie the formatting
is a bit different, but this should be irrelevant.
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="articles">
<html><head><title><xsl:text>Reference</xsl:text></title></head>
<body>
<h1><xsl:text>Articles</xsl:text></h1>
<table border="0" cellpadding="2" cellspacing="2">
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="publication">
<tr>
<td><b><a href="child::filename"><xsl:value-of
select="title"/></a></b></td>
</tr>
<tr>
<td><xsl:value-of select="authors"/></td>
</tr>
<tr>
<td><xsl:value-of select="source"/><xsl:text>,
</xsl:text><xsl:value-of select="date"/></td>
</tr>
<tr>
<td colspan="3"><br></br></td>
</tr>
</xsl:template>
</xsl:stylesheet>
Can someone please help a novice out?
Thanks!