R
rick
Greetings,
I am trying to generate an html table that looks through the following
xml source and lists links to all of the files (resource-file) and
finds the resource-forms that match those file names and adds the
appropriate file description next to the link to the filename. The xslt
code that I've included doesn't work but gives an idea of what I'm
trying to do. Through my research I believe that using keys and/or
template matching my be the better way to go, but I'm not sure how to
code them. I recognize that the xml structure is a little awkward but
that's what I have to work with. Thanks in advance for any
suggestions.
Rick
XML source
<artifact>
<resource-file>
<artifact>
<displayName>file1.doc</displayName>
<uri>location of file1</uri>
</artifact>
<artifact>
<displayName>file2.doc</displayName>
<uri>location of file2</uri>
</artifact>
</resource-file>
<resource-form>
<file_name>file1.doc</file_name>
<resource_description>file1.doc
description</resource_description>
</resource-form>
<resource-form>
<artifact>
<file_name>file2.doc</file_name>
<resource_description>file1.doc
description</resource_description>
</artifact>
<artifact>
<file_name>file3.doc</file_name>
<resource_description>file3.doc
description</resource_description>
</artifact>
<artifact>
<file_name>file4.doc</file_name>
<resource_description>file4.doc
description</resource_description>
</artifact>
</resource-form>
</artifact>
Desired output
Resource File(s) File Description
(link to file1.doc) file1.doc description
(link to file2.doc) file2.doc description
nonworking xslt code
<table>
<tr>
<td>Resource File(s)</td>
<td>File Description</td>
</tr>
<tr>
<xsl:for-each select="resource-file/artifact">
<xsl:variable name="filename" select="metaData/displayName"/>
<xsl:variable name="filelocation" select="fileArtifact/uri"/>
<xsl:for-each select="resource-form/artifact"['file_name=$filename']>
<tr>
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="$filelocation"/>
</xsl:attribute>
<xsl:attribute name="target">blank</xsl:attribute>
<xsl:value-of select="$filename"/>
</a>
</td>
<td>
<b>Resource Description:</b>
<xsl:value-of
select="structuredData/resource-form/resource_description"/>
</td>
</tr>
</xsl:for-each>
</xsl:for-each>
</tr>
</table>
I am trying to generate an html table that looks through the following
xml source and lists links to all of the files (resource-file) and
finds the resource-forms that match those file names and adds the
appropriate file description next to the link to the filename. The xslt
code that I've included doesn't work but gives an idea of what I'm
trying to do. Through my research I believe that using keys and/or
template matching my be the better way to go, but I'm not sure how to
code them. I recognize that the xml structure is a little awkward but
that's what I have to work with. Thanks in advance for any
suggestions.
Rick
XML source
<artifact>
<resource-file>
<artifact>
<displayName>file1.doc</displayName>
<uri>location of file1</uri>
</artifact>
<artifact>
<displayName>file2.doc</displayName>
<uri>location of file2</uri>
</artifact>
</resource-file>
<resource-form>
<file_name>file1.doc</file_name>
<resource_description>file1.doc
description</resource_description>
</resource-form>
<resource-form>
<artifact>
<file_name>file2.doc</file_name>
<resource_description>file1.doc
description</resource_description>
</artifact>
<artifact>
<file_name>file3.doc</file_name>
<resource_description>file3.doc
description</resource_description>
</artifact>
<artifact>
<file_name>file4.doc</file_name>
<resource_description>file4.doc
description</resource_description>
</artifact>
</resource-form>
</artifact>
Desired output
Resource File(s) File Description
(link to file1.doc) file1.doc description
(link to file2.doc) file2.doc description
nonworking xslt code
<table>
<tr>
<td>Resource File(s)</td>
<td>File Description</td>
</tr>
<tr>
<xsl:for-each select="resource-file/artifact">
<xsl:variable name="filename" select="metaData/displayName"/>
<xsl:variable name="filelocation" select="fileArtifact/uri"/>
<xsl:for-each select="resource-form/artifact"['file_name=$filename']>
<tr>
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="$filelocation"/>
</xsl:attribute>
<xsl:attribute name="target">blank</xsl:attribute>
<xsl:value-of select="$filename"/>
</a>
</td>
<td>
<b>Resource Description:</b>
<xsl:value-of
select="structuredData/resource-form/resource_description"/>
</td>
</tr>
</xsl:for-each>
</xsl:for-each>
</tr>
</table>