Nesting

jjjlda

Usenet Archive
Joined
May 3, 2004
Messages
1
Reaction score
0
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!
 

Toivo Lainevool

Usenet Archive
Joined
Jun 10, 2000
Messages
14
Reaction score
0
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.
To get the href tag working you want to to something like this in your stylesheet:

<a>
<xsl:attribute name="href"><xsl:value-of
select="filename"/></xsl:attribute>
<xsl:value-of select="title"/>
</a>

Hope that helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top