Hello,
Before I begin I am using:
Vendor: Microsoft
Vendor URL: http://www.microsoft.com
I am trying to build a dynamic table from xml data using xsl:stylesheet. I
am 2/3 complete. Using solutions from this list I was able to complete
the first two parts.
My table consists of Room Locations in the column headers, and time, start
and end, at the beginning of each row. The problems begin when I try to
add data to each row based on xsl:if statements.
Here is an excerpt from my xml file:
--Start XML
<?xml version="1.0" encoding="UTF-8"?>
<topics>
<topic>
<name>Introduction to LotusScript for Lotus Notes and Domino</name>
<start>0800</start>
<end>1000</end>
<location>SW 1-4</location>
</topic>
<topic>
<name>Introduction to Lotus Domino and WebSphere Integration</name>
<start>0800</start>
<end>1000</end>
<location>DL S. Hemisphere I-II</location>
</topic>
<topic>
<name>Integrating Lotus Domino with Corporate Data and Business
Logic</name>
<start>0800</start>
<end>1000</end>
<location>DL S. Hemisphere III-V</location>
</topic>
<topic>
<name>Integrating Lotus Domino with Corporate Data and Business
Logic</name>
<start>1315</start>
<end>1515</end>
<location>SW 10</location>
</topic>
<topic>
<name>Business Development Opening General Session</name>
<start>0800</start>
<end>1045</end>
<location>Y&B GH N-S</location>
</topic>
<topic>
<name>Tools of the Trade: Analyzing Performance of Your Lotus Domino
Server</name>
<start>1015</start>
<end>1215</end>
<location>DL S. Hemisphere III-V</location>
</topic>
</topics>
--End XML
Here is my entire xsl stylesheet: see -------notes----------
--Start XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<head><title>Day 1</title>
</head>
<body>
<table border="3" width="100%">
<xsl:apply-templates select="topics" />
</table>
</body>
</html>
</xsl:template>
<xsl:template match="topics">
<xsl:variable name="unique-rooms"
select="//topics/topic/location[not(. =
preceding::location)]" />
<th><td>Start</td><td>End</td>
<xsl:for-each select="$unique-rooms">
<xsl:sort select="." />
<td><xsl:value-of select="." /> </td>
</xsl:for-each>
</th>
<xsl:for-each select="topic/start">
<xsl:sort select="." />
<tr><td></td>
<td><xsl:value-of select="." /> </td>
<td><xsl:value-of select="../end" /></td>
<xsl:for-each select="$unique-rooms">
----This is the part that doesn't work, how I want it to
work---------------------
<xsl:if test=". = ../location">
---------This xsl:if is always true, and prints the name in every column
on each row------------
<td><xsl:value-of select="../name"
/></td>
</xsl:if>
<xsl:if test=". != ../location">
<td></td>
</xsl:if>
</xsl:for-each>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
--End XSL
If there is more information you need please email me. I don't understand
why the xsl:if is always true if I am comparing 2 different things, unless
the path is changed for the ../location once it is inside the xsl:for-each
select="$unique-rooms". If that is that case how to I refer to the
location that is associated with the proper start time? If I test
../location outside of the xsl:for-each select="$unique-rooms" then it
prints the proper location.
Thanks,
Jeff
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list