Hi all,
I've been working on a little XML to XSLT project (i'm new to it so i'm experimenting) and have come across a problem which is frustrating me. I have an XML file in the form of:
XML file:
<Orders>
<Order>
<Name>
<Address>
<TelNo>
<OrderTotal>
<Item>
<SuppCode>
<Desc>
<Price>
</Item>
<Item>
<SuppCode>
<Desc>
<Price>
</Item>
<Item>
<SuppCode>
<Desc>
<Price>
</Item>
</Order>
<Orders>
XSLT file:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
<xsl:template match="/">
<HTML>
<BODY>
<font face="Arial" size="4">Purchase Orders</font>
<xsl:apply-templates />
</BODY>
</HTML>
</xsl:template>
<xsl:template match="/Orders">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="1">
<TR bgcolor="#6090CF" >
<TD STYLE="fontface:Arial"><font color="white"><CENTER><STRONG>Name</STRONG></CENTER></font></TD>
<TD STYLE="fontface:Arial"><font color="white"><CENTER><STRONG>Address</STRONG></CENTER></font></TD>
<TD STYLE="fontface:Arial"><font color="white"><CENTER><STRONG>TelNo</STRONG></CENTER></font></TD>
<TD STYLE="fontface:Arial"><font color="white"><CENTER><STRONG>OrderTotal</STRONG></CENTER></font></TD>
<TD STYLE="fontface:Arial"><font color="white"><CENTER><STRONG>SuppCode</STRONG></CENTER></font></TD>
<TD><font face="Arial" size="2" color="white"><CENTER><STRONG>Description</STRONG></CENTER></font></TD>
<TD><font face="Arial" size="2" color="white"><CENTER><STRONG>Price</STRONG></CENTER></font></TD>
</TR>
<xsl:for-each select="Order/Item">
<TR bgcolor="LightGreen">
<TD>
<font face="Arial" size="2"><xsl:value-of select="Name"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="Address"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="TelNo"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="OrderTotal"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="SuppCode"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="Desc"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="Price"/></font>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</xsl:template>
The "Item" node can occur many times but i can only get it to display once in XSLT. What should i be doing? I'd appreciate any help or any direction to guides/tutorials.
Thanks in advance.
I've been working on a little XML to XSLT project (i'm new to it so i'm experimenting) and have come across a problem which is frustrating me. I have an XML file in the form of:
XML file:
<Orders>
<Order>
<Name>
<Address>
<TelNo>
<OrderTotal>
<Item>
<SuppCode>
<Desc>
<Price>
</Item>
<Item>
<SuppCode>
<Desc>
<Price>
</Item>
<Item>
<SuppCode>
<Desc>
<Price>
</Item>
</Order>
<Orders>
XSLT file:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
<xsl:template match="/">
<HTML>
<BODY>
<font face="Arial" size="4">Purchase Orders</font>
<xsl:apply-templates />
</BODY>
</HTML>
</xsl:template>
<xsl:template match="/Orders">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="1">
<TR bgcolor="#6090CF" >
<TD STYLE="fontface:Arial"><font color="white"><CENTER><STRONG>Name</STRONG></CENTER></font></TD>
<TD STYLE="fontface:Arial"><font color="white"><CENTER><STRONG>Address</STRONG></CENTER></font></TD>
<TD STYLE="fontface:Arial"><font color="white"><CENTER><STRONG>TelNo</STRONG></CENTER></font></TD>
<TD STYLE="fontface:Arial"><font color="white"><CENTER><STRONG>OrderTotal</STRONG></CENTER></font></TD>
<TD STYLE="fontface:Arial"><font color="white"><CENTER><STRONG>SuppCode</STRONG></CENTER></font></TD>
<TD><font face="Arial" size="2" color="white"><CENTER><STRONG>Description</STRONG></CENTER></font></TD>
<TD><font face="Arial" size="2" color="white"><CENTER><STRONG>Price</STRONG></CENTER></font></TD>
</TR>
<xsl:for-each select="Order/Item">
<TR bgcolor="LightGreen">
<TD>
<font face="Arial" size="2"><xsl:value-of select="Name"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="Address"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="TelNo"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="OrderTotal"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="SuppCode"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="Desc"/></font>
</TD>
<TD>
<font face="Arial" size="2"><xsl:value-of select="Price"/></font>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</xsl:template>
The "Item" node can occur many times but i can only get it to display once in XSLT. What should i be doing? I'd appreciate any help or any direction to guides/tutorials.
Thanks in advance.