PDA

View Full Version : Remote XML Feed / Local XSLT. Transformation in browser. Can't get it to execute.


sosarder
09-01-2006, 01:27 PM
Hi all,

I hope someone will be able to help me. I am pretty familiar with static and dynamic web technologies but this is my first foray into XML and XSLT.

I am trying to make a page which makes use of the Cafepress XML feed here: http://api.cafepress.com/index.asmx/AdvancedSearch?query=Tall%20Oaks%20Band%20Camp&version=1&apiKey=06100754d82536fd7a321c0f4b4d55331d3885605937fb57&productTypes=2,4,5,6,7,23,38,45,69,70,72,89,96,102,103,106,107,108,109,110,111,112,113,114,115,126,1 28,129,133,134,135,136&startResults=0&maxResults=45&maxProductsPerDesign=1&sort=by_score_desc

Basically I want to run an XSL transformation on that data to display it on my site so that people can click through and make a purchase (yes it's an affiliate XML feed).

I have already written the XSL and can get it to run using a locally saved copy of the XML data. The page in question is: http://www.talloaksbandcamp.com/index.asp.

My specific problem is the exact coding to instruct the browser to collect the remote XML feed from the cafe press website and run the local XSL transformation on.

The code I am currently using at the above URL (index.asp) is:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<%
Dim objXML
Dim objXSL
Dim strHTML

'Load the XML File
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.load(Server.MapPath("cafepress.xml"))

'Load the XSL File
Set objXSL = Server.CreateObject("Microsoft.XMLDOM")
objXSL.async = False
objXSL.load(Server.MapPath("cafepress2.xsl"))

' Transform the XML file using the XSL stylesheet
strHTML = objXML.transformNode(objXSL)

Set objXML = Nothing
Set objXSL = Nothing

' Spit out the resulting HTML... the data comes from the
' .xml file, but the formatting of the results depends
' completely upon the .xsl file.
Response.Write strHTML
%>

</body>
</html>

I am struggling with the line:

objXML.load(Server.MapPath("cafepress.xml"))

and have replaced the XML block with:

'Load the XML File
'Set objXML = Server.CreateObject("Microsoft.XMLDOM")
Set objXML = Server.CreateObject("Msxml2.DomDocument")
objXML.async = False
objXML.setProperty "ServerHTTPRequest", true
objXML.load("http://api.cafepress.com/index.asmx/AdvancedSearch?query=Tall%20Oaks%20Band%20Camp&version=1&apiKey=06100754d82536fd7a321c0f4b4d55331d3885605937fb57&productTypes=2,4,5,6,7,23,38,45,69,70,72,89,96,102,103,106,107,108,109,110,111,112,113,114,115,126,1 28,129,133,134,135,136&startResults=0&maxResults=45&maxProductsPerDesign=1&sort=by_score_desc")
'objXML.load(Server.MapPath("cafepress.xml"))

which runs but does not display anything.

If you want to you can see the static (copied) xml here:

http://www.talloaksbandcamp.com/cafepress.xml

and the XSLT here:

http://www.talloaksbandcamp.com/cafepress2.xsl

I realise that the XSLT may be a little clumsy (as the first I've written) but for the moment it does what I want and I can optimise it when I get a little more familiar with XSL.

Can anyone help me with the code in the index.asp page or should I post in the ASP forum?

Many Thanks

Nigel

SecretPete
10-05-2006, 05:52 AM
Secret Pete with a magic link...

http://www.dotnetjunkies.com/WebLog/nettricks/default.aspx