?
Solved

classic asp using xml and xslt transform response sending resulting html without xml values

Posted on 2009-02-21
2
Medium Priority
?
1,386 Views
Last Modified: 2013-11-18
I have an asp page that when first loaded writes HTML to the client browser.

The resulting HTML is generated with the ASP code using a XML-XSLT transformation.

The problem is that only the HTML portion of the XSLT document is returned. The XSLT code that is supposed to generate values from the XML file do not return from the server-side execution of the ASP page.

Can anyone see why?

this is the ASP page (.asp)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
 
 
<% 
	'-----------------------------------------------------------
	'The "loadXMLFile" Function accepts two parameters.
	'strXMLFile - The path and file name of the XML file.
	'strXSLFilee - The path and file name of the XSL file.
	'----------------------------------------------------------- 
 
 
strXMLFileName=Server.MapPath("products_tester.xml")	
strXSLFile=Server.MapPath("products_tester.xsl")
 
fileHTMLCreated=loadXMLFile(strXMLFile, strXSLFile)	
	
	Function loadXMLFile(strXMLFile, strXSLFile)
	
	 'Declare local variables
	 Dim objXML
	 Dim objXSL
	
	
	 'Instantiate the XMLDOM Object that will hold the XML file.
	 'set objXML = Server.CreateObject("Microsoft.XMLDOM")
	  set objXML = Server.CreateObject("Msxml2.DOMDocument.4.0")
	 'Turn off asyncronous file loading.
	 objXML.async = false
	
	 'Load the XML file.
	 objXML.load(strXMLFile)
	
	
	 'Instantiate the XMLDOM Object that will hold the XSL file.
	 'set objXSL = Server.CreateObject("Microsoft.XMLDOM")
	 set objXSL =Server.CreateObject("Msxml2.DOMDocument.4.0")
	 'Turn off asyncronous file loading.
	 objXSL.async = false
	
	 'Load the XSL file.
	 objXSL.load(strXSLFile)
	 
	
	
	
	 'Use the "transformNode" method of the XMLDOM to apply the
	 'XSL stylesheet to the XML document. Then the output is
	 'written to the client.
	 Response.Write(objXML.transformNode(objXSL))
	  set objXML = nothing
	set objXSL = nothing
	 
	End Function
	
%>
 
this is the xml file: (products_tester.xml)
 
<?xml version="1.0"?>
<PRODUCTS>
	<PRODUCT>
		<NAME>ThreeGallonWaterBottle</NAME>
		<PRICE>5.00</PRICE>
		<IMAGEURL>images/water_bottle_sm.jpg</IMAGEURL>
	</PRODUCT>
</PRODUCTS>
 
this is the xslt file (products_tester.xsl)
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
 
  <xsl:template match="/">
    
 
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 
<title>DEXTEL.NET Excercise</title>
 
<link rel="stylesheet" type="text/css" href="write_xml3.css" />
<script type="text/javascript" src="write_xml3.js"></script>
 
            
</head>
<body>
 
<table width="100%" border="0" style="position:absolute;top:20%;">
  <tr>
  	<td width="33%">
  
  	</td>
    <td width="33%">
    	<form method="post" name="form" action="">
        <table width="100%" border="0" >
 			<tr>
    			<td colspan="2" align="left"><strong>Enter new product:</strong></td>
  			</tr>
  			<tr>
    			<td>Name:</td>
    			<td><input name="txtName" type="text" /></td>
  			</tr>
 			<tr>
    			<td>Price:</td>
    			<td><input name="txtPrice" type="text" /></td>
  			</tr>
  			<tr>
    			<td>Image URL:</td>
    			<td><input name="txtImageURL" type="text" /></td>
 			</tr>
  			<tr>
    			<td></td>
    			<td><input type="button" value="Submit" onclick="showProducts(this.value)"/></td>
  			</tr>
            </table>
		</form>
    </td>
    <td width="33%">
    
    </td>
  </tr>
</table>
 
<ul id="slideshow"> 
 
 <xsl:for-each select="/PRODUCTS/PRODUCT">
    
    <li><img>
    <xsl:attribute name="src">
    	<xsl:value-of select="IMAGEURL"/>
    </xsl:attribute>
    
    </img><br />
    
        <p align="center"><xsl:value-of select="NAME"/><br />
       </p>
        <p align="center"><xsl:value-of select="PRICE"/></p>
       
    
    </li>
 
   </xsl:for-each>
 
                                  
</ul>
 
 
<script type="text/javascript">
init();
</script>
  
    </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Open in new window

0
Comment
Question by:jumprooster
  • 2
2 Comments
 

Author Comment

by:jumprooster
ID: 23701212
i have tested this by just looking at the xml (linked to the xslt file with a stylesheet relationship) in the browser so it seems that the problem is with the asp code

??
0
 

Accepted Solution

by:
jumprooster earned 0 total points
ID: 23701226
found the problem, always happens right after I ask someone a question

the variable strXMLFileName for the XML file not the same name as the one passed to the function that loads the xml file and the xsl file
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question