View Full Version : Need help with a complex table layout!
sethwb
12-17-2009, 10:49 PM
<prodmain>
..
<product>
..
<listofmedia>
<media>
<name>Orange</name>
<type>Document/Bulletin</type>
</media>
<media>
<name>Eggnog</name>
<type>Photography/Product/Application Image</type>
</media>
<media>
<name>Bacon</name>
<type>Document/Bulletin</type>
</media>
</listofmedia>
..
</product>
</prodmain>
I need to separate each document type out as such:
<tr><td>Bulletins:</td></tr>
<tr><td>
Orange<br/>
Bacon
</td></tr>
<tr><td>Application Image</td></tr>
Eggnog
</tr>
</td>
I have tried several different things but I'm afraid I need someone with true XSLT vision to understand how this can be done. I am working with xslt 1.0.
oesxyl
12-17-2009, 11:28 PM
<prodmain>
..
<product>
..
<listofmedia>
<media>
<name>Orange</name>
<type>Document/Bulletin</type>
</media>
<media>
<name>Eggnog</name>
<type>Photography/Product/Application Image</type>
</media>
<media>
<name>Bacon</name>
<type>Document/Bulletin</type>
</media>
</listofmedia>
..
</product>
</prodmain>
I need to separate each document type out as such:
<tr><td>Bulletins:</td></tr>
<tr><td>
Orange<br/>
Bacon
</td></tr>
<tr><td>Application Image</td></tr>
Eggnog
</tr>
</td>
I have tried several different things but I'm afraid I need someone with true XSLT vision to understand how this can be done. I am working with xslt 1.0.
try this:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<table>
<xsl:apply-templates select="prodmain/product/listofmedia/media"/>
</table>
</xsl:template>
<xsl:template match="media">
<tr>
<td>
<xsl:value-of select="type"/>
</td>
</tr>
<tr>
<td>
<xsl:value-of select="name"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
best regards
sethwb
12-18-2009, 11:16 PM
I think I failed to communicate the true problem I need help with here.
The problem is that every "document" to show up under only one box with one title "Documents"
and every "picture" to only show up under one heading that says "Picture"
etc.
but so far this has not been very successful for me as im not used to having variables that aren't really variable, etc. (yet)
oesxyl
12-19-2009, 12:22 AM
I think I failed to communicate the true problem I need help with here.
The problem is that every "document" to show up under only one box with one title "Documents"
and every "picture" to only show up under one heading that says "Picture"
etc.
but so far this has not been very successful for me as im not used to having variables that aren't really variable, etc. (yet)
I'm not sure I understand. You want to group name elements by type?
best regards
sethwb
12-21-2009, 06:30 PM
Indeed,
I need to have the 3 "brochures" under the brochure section
and the 4 or 5 "instruction manuals" under their own heading as well (appearing only once)
Brochures:
product 1 brochure (pdf 20 kb)
product 2 brochure (pdf 22 kb)
product 3 brochure (pdf 41 kb)
Instruction Manuals:
product 1 manual (pdf 220 kb)
product 2 manual (pdf 222 kb)
product 3 manual (pdf 241 kb)
the challenge I'm having is that the node type is stored as a sub node of the "media" node much like all the other informationm about that media node, such as the size purpose link etc... so you can't exactly just say "if type=instructions manual then put in the instructions TD" - right?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.