Soldato
- Joined
- 27 Mar 2003
- Posts
- 2,710
Ok. I am probably missing something obvious here but here is my problem.
I am try to build a website using xslt transformation.
I have an xml document which has the following structure.
now each of the elements have attributes and the structure I have employeed is to have ROOTITEM4 CHILD Element link all the other items together
ie.
so I have an xlst file which is:
so it loops through and fills in all the columns except the column that uses the second for-each loop.
what am I do wrong? Is it even possible to do what I want to do?
I am try to build a website using xslt transformation.
I have an xml document which has the following structure.
Code:
<ROOT>
<ROOTITEM1/>
<ROOTITEM1/>
<ROOTITEM1/>
<ROOTITEM1/>
<ROOTITEM1/>
<ROOTITEM1/>
<ROOTITEM2>
<CHILDITEM1/>
<CHILDITEM1/>
</ROOTITEM2>
<ROOTITEM2/>
<ROOTITEM2/>
<ROOTITEM2/>
<ROOTITEM3/>
<CHILDITEM2/>
<CHILDOFCHILDITEM1/>
</CHILDITEM2>
</ROOTITEM3>
<ROOTITEM4>
<CHILDITEM3/>
<CHILDITEM3/>
<CHILDITEM3/>
</ROOTITEM4>
</ROOT>
now each of the elements have attributes and the structure I have employeed is to have ROOTITEM4 CHILD Element link all the other items together
ie.
Code:
<CHILDITEM3 ID="1" ROOTITEMID="1" ROOTITEM2ID="3" />
so I have an xlst file which is:
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes"/>
<xsl:template match ="/" xml:space="default">
<h1>A header</h1>
<table border="1px">
<tr>
<th>Item1</th>
<th>Item2</th>
<th>Item3</th>
<th>Item4</th>
<th>Item5</th>
</tr>
<xsl:for-each select="ROOT/ROOTITEM4/CHILDITEM3" xml:space="default" >
<xsl:sort select="@CourseDateStart"/>
<xsl:variable name="varItem1ID" select="@ChildITEM2ID"/>
<tr>
<td>
<xsl:for-each select ="../ROOTITEM3" xml:space="default">
<xsl:if test="$varItem1ID = CHILDITEM2/@ID" xml:space="default">
<p>hello</p>
</xsl:if>
</xsl:for-each>
</td>
<td>
<xsl:value-of select="substring(@Item1ID1,7,2)"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring(@Item1ID,5,2)"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring(@Item1ID,1,4)"/>
<xsl:text> To </xsl:text>
<xsl:value-of select="substring(@Item2ID,7,2)"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring(@Item2ID,5,2)"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="substring(@Item2ID,1,4)"/>
</td>
<td>
test
</td>
<td>
test
</td>
<td>
test
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet
so it loops through and fills in all the columns except the column that uses the second for-each loop.
what am I do wrong? Is it even possible to do what I want to do?