I have a simple XML file as shown below and a pretty simple XSL transform. I want to color the shipdate different if the status is shipped.
--<report.xml>--
<?xml version="1.0"?>
<report>
<sale>
<customer>Customer X</customer>
<so>123</so>
<contract>pending</contract>
<stage>Mature</stage>
<shipdate status="shipped">08/09/2002</shipdate>
</sale>
<sale>
<customer>Customer A</customer>
<so>123</so>
<contract>pending</contract>
<stage>Mature</stage>
<shipdate status="ordered">08/09/2002</shipdate>
</sale>
</report>
--<End Report.xml>--
--<Report.xsl>--
<?xml version="1.0"?>
<HTML xmlns:xsl=" <BODY STYLE="font-family:Tahoma; font-size:12pt; background-color:#ffffff">
<DIV STYLE="font-weight:bold; font-size=12pt">
Acme Engineering
</DIV>
<TABLE border="1" cellspacing="0">
<TR>
<TD>Customer</TD>
<TD>Sales Order</TD>
<TD>Contract #</TD>
<TD>Stage</TD>
<TD>Ship Date</TD>
</TR>
<xsl:for-each select="sale" order-by="+ customer">
<TR>
<TD><xsl:value-of select="customer"/></TD>
<TD><xsl:value-of select="so"/></TD>
<TD><xsl:value-of select="contract"/></TD>
<TD><xsl:value-of select="stage"/></TD>
<xsl:choose>
<xsl:when test="shipdate/@status='shipped'">
<TD bgcolor="#99AAFF"><xsl:value-of select="shipdate"/></TD>
</xsl:when>
<xsl
therwise>
<TD><xsl:value-of select="shipdate"/></TD>
</xsl
therwise>
</xsl:choose>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
--<End report.xsl>--
--<ASP Code to generate transform>--
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Server-side XML/XSL Merging</TITLE>
</HEAD>
<BODY bgcolor="#ffffff">
<%
Dim xmlDoc, xslDoc
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM"
Set xslDoc = Server.CreateObject("Microsoft.XMLDOM"
xmlDoc.async = False
xmlDoc.Load(Server.MapPath("report.xml"
)
xslDoc.async = False
xslDoc.Load(Server.MapPath("report.xsl"
)
Response.Write(xmlDoc.documentElement.transformNode(xslDoc.documentElement))
Set xslDoc = Nothing
Set xmlDoc = Nothing
%>
</BODY>
</HTML>
--<End of ASP Code>--
The problem is this line:
<xsl:when test="shipdate/@status='shipped'">
It doesn't like comparing the value in the attribute to the value of 'shipped'. If I take out the comparison like this, it will run the transform, but I get the same color for all ship dates.
<xsl:when test="shipdate/@status">
So the question is... how do I compare an attribute to a literal to make the transform work?
Thanks in advance,
Snaggs
tribesaddict@swbell.net
Life can only be understood backwards; but it must be lived forwards.
--<report.xml>--
<?xml version="1.0"?>
<report>
<sale>
<customer>Customer X</customer>
<so>123</so>
<contract>pending</contract>
<stage>Mature</stage>
<shipdate status="shipped">08/09/2002</shipdate>
</sale>
<sale>
<customer>Customer A</customer>
<so>123</so>
<contract>pending</contract>
<stage>Mature</stage>
<shipdate status="ordered">08/09/2002</shipdate>
</sale>
</report>
--<End Report.xml>--
--<Report.xsl>--
<?xml version="1.0"?>
<HTML xmlns:xsl=" <BODY STYLE="font-family:Tahoma; font-size:12pt; background-color:#ffffff">
<DIV STYLE="font-weight:bold; font-size=12pt">
Acme Engineering
</DIV>
<TABLE border="1" cellspacing="0">
<TR>
<TD>Customer</TD>
<TD>Sales Order</TD>
<TD>Contract #</TD>
<TD>Stage</TD>
<TD>Ship Date</TD>
</TR>
<xsl:for-each select="sale" order-by="+ customer">
<TR>
<TD><xsl:value-of select="customer"/></TD>
<TD><xsl:value-of select="so"/></TD>
<TD><xsl:value-of select="contract"/></TD>
<TD><xsl:value-of select="stage"/></TD>
<xsl:choose>
<xsl:when test="shipdate/@status='shipped'">
<TD bgcolor="#99AAFF"><xsl:value-of select="shipdate"/></TD>
</xsl:when>
<xsl
<TD><xsl:value-of select="shipdate"/></TD>
</xsl
</xsl:choose>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
--<End report.xsl>--
--<ASP Code to generate transform>--
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Server-side XML/XSL Merging</TITLE>
</HEAD>
<BODY bgcolor="#ffffff">
<%
Dim xmlDoc, xslDoc
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM"
Set xslDoc = Server.CreateObject("Microsoft.XMLDOM"
xmlDoc.async = False
xmlDoc.Load(Server.MapPath("report.xml"
xslDoc.async = False
xslDoc.Load(Server.MapPath("report.xsl"
Response.Write(xmlDoc.documentElement.transformNode(xslDoc.documentElement))
Set xslDoc = Nothing
Set xmlDoc = Nothing
%>
</BODY>
</HTML>
--<End of ASP Code>--
The problem is this line:
<xsl:when test="shipdate/@status='shipped'">
It doesn't like comparing the value in the attribute to the value of 'shipped'. If I take out the comparison like this, it will run the transform, but I get the same color for all ship dates.
<xsl:when test="shipdate/@status">
So the question is... how do I compare an attribute to a literal to make the transform work?
Thanks in advance,
Snaggs
tribesaddict@swbell.net
Life can only be understood backwards; but it must be lived forwards.