View Single Post
  #1 (permalink)  
Old November 7th, 2003, 01:30 PM
kenneth02 kenneth02 is offline
Registered User
 
Join Date: Nov 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Server side xsl transformation problems (ASP, IIS)


Hi guys,

I'm having problems getting a server side xsl transformation of an xml file to work. I'm using ASP with IIS to try to spit out HTML, but I'm really stuck. I think my code is ok, but I'm wondering if I've got the right parsers etc. on my machine. I must admit to being a bit lost as to what I need and where it should go. Here are short source files I've been using to attempt the transformation:
------
ASP
------
<%@ LANGUAGE=JScript %>
<html>
<head></head>
<body>
<%
var sourceFile = Server.MapPath("data.xml");
var styleFile = Server.MapPath("data.xsl");

var source = Server.CreateObject("MSXML2.DOMDocument");
var style = Server.CreateObject("MSXML2.DOMDocument");

//var source = new ActiveXObject("Msxml2.DOMDocument.4.0");
//var style = new ActiveXObject("Msxml2.DOMDocument.4.0");

source.async = false;
source.resolveExternals = false;
source.load(sourceFile);

style.async = false;
style.resolveExternals = false;
style.load(styleFile);


Response.Write(source.transformNode(style));

%>

</body>
</html>
------
XSL
------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="uri:xsl">
<xsl:template match="/">

<table>
<tr>
<td>Title</td>
<td>Author</td>
</tr>

<xsl:for-each select="CATALOG/BOOK">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:for-each>
</table>
</xsl:template>

<xsl:template match="BOOK">
    <td><xsl:value-of select="TITLE"/></td>
    <td><xsl:value-of select="AUTHOR"/></td>
</xsl:template>
</xsl:stylesheet>
------
XML
------
<?xml version="1.0"?>
<CATALOG>
<BOOK>
<TITLE>Introduction to talking shy</TITLE>
<AUTHOR>John Crop</AUTHOR>
</BOOK>

<BOOK>
<TITLE>Introduction to walking</TITLE>
<AUTHOR>John Walk</AUTHOR>
</BOOK>

<BOOK>
<TITLE>Introduction to eating crisps</TITLE>
<AUTHOR>John Fug</AUTHOR>
</BOOK>

<BOOK>
<TITLE>Introduction to smelling like a dog</TITLE>
<AUTHOR>John Acs</AUTHOR>
</BOOK>

</CATALOG>
------
The output is simply the unformatted table headings: "Title Author"

I'd appreciate any tips you might have!

Thanks-
K