Reputation: 25
I'm working on transforming some XML into HTML via XSL and am having some trouble displaying links. The XML looks like this:
<c02 level="file">
<did>
<container type="Box">1</container>
<container type="Folder">2</container>
<unittitle>Folder A, </unittitle>
<unitdate>2001</unitdate>
<daogrp>
<daoloc label="Image" href="www.test.com" role="Image/jpeg">
<daodesc><p>Document</p>
</daodesc>
</daoloc>
</daogrp>
</did>
<scopecontent>
<p>1 page</p>
</scopecontent>
</c02>
My expected HTML is something like this:
<tr>
<td valign="top">1</td>
<td valign="top">2</td>
<td valign="top" colspan="10">Folder A, 2001</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td valign="top" colspan="8"><a href="www.test.com">Document<br />
</a></td>
and my XSL currently looks like this:
<xsl:template match="daoloc">
<xsl:choose>
<xsl:when test="@role='Image/jpeg'">
<img src="{@href}" altrender="{@Document}"/>
</xsl:when>
<xsl:when test="@role='new'">
<a href="{@href}">
<xsl:value-of select="@Document"/>
</a>
</xsl:when>
</xsl:choose>
</xsl:template>
I've played around for a while with little success. How can I twist the XSL to get these links to display? Thanks for any assistance in advance.
Upvotes: 2
Views: 907
Reputation: 117175
Well, the following template:
<xsl:template match="daoloc">
<p>
<a href="{@href}">
<xsl:apply-templates/>
</a>
</p>
</xsl:template>
applied to your input (after adding a space between the label
and href
attributes!), will return:
<p>
<a href="www.test.com">Document</a>
</p>
Upvotes: 1