ASP generated XSL


  Hi !

I've 2 asp files. The first one, user.asp returns with a user info, such like this:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="userxsl.asp"?>
<data>
     <User Active="1" UserName="stewe" Name="Stewe" ID="1"/>
</data>

It works with COM objects.
The second asp returns (should return) an xsl that depends on some settings. Language, style, etc.
Of course the user info xml specifies the xsl file.

If I navigate to the user info asp(without specified xsl), it appears correctly as native xml data.
When I navigate to the user xsl asp, it appears correctly as native xml data.

When I try to show the content, this error occurs:

/-------------------
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.
--------------------/
This is a very simple xsl (just for example), and it works alone:

/--------------------
<%@language="JScript"%>
<%
Response.Buffer=true;
Response.ContentType="text/xml";
%>
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
     hello
</xsl:template>
</xsl:stylesheet>
----------------------/
Now it's in very simplified state, because of the error. Normally it includes language - based string replacing, etc.

Important.
If I rename the userxsl.asp to userxsl.xsl, and I clear asp-based lines, then it works correctly, so 'hello' appears.
Maybe I've forgotten something important (header-setting, or such like this).

   Stewe
LVL 1
steweAsked:
Who is Participating?
 
crw030Connect With a Mentor Commented:
stewe,

I don't know what files you guys sent but this works fine for me:

userxsl.asp
==============
<%@language="JScript"%>
<%
Response.Buffer=true;
Response.Expires=-1;
Response.ContentType="text/xml";
%>
<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
version="1.0">
<xsl:template match="/">
 <%Response.Write("HeLLO - ");%><xsl:for-each select="data/User"><STRONG><xsl:value-of select="@Name"/></STRONG><DIV>UserName:<xsl:value-of select="@UserName"/></DIV></xsl:for-each>
</xsl:template>
</xsl:stylesheet>




user.asp
=========
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="userxsl.asp"?>
<data>
    <User Active="1" UserName="stewe" Name="Stewe" ID="1"/>
</data>




Result  (HTML looks a little different)
===========
HeLLO - Stewe
UserName:stewe


Now:  1. I'm just learning XSLT style sheets so I probably butchered it (but it works! Yeah for me!)

2.  b1xml2 is much better at all that stuff

Thought it would be nice to get a second opinion.

BTW. I've noticed on the userxsl.asp *ONLY* I get meta-data back (hmmmmm)

I'm using IE6 on a windows2000 IIS server (couple sp behind I think)
0
 
b1xml2Commented:
<%@language="JScript"%>
<%
Response.Buffer=true;
Response.ContentType="text/xml";
//Note where the pi is located.
%><?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
    hello
</xsl:template>
</xsl:stylesheet>
0
 
b1xml2Commented:
Also, if you do not have MSXML3 SP2 installed (comes with MSIE 6.0), go install it from
http://msdn.microsoft.com/xml ---> MSXML3 SP2.

MSXML 3 SP2 installs in replace mode.

If you have not installed MSXML3 (RTM or SP1) in replace mode via xmlinst from Microsoft, you will have MSXML2 as the default MSIE XML Parser and it does not support the XSLT dialect.

Moral of the story:
Go with scripted transforms (client or server) and avoid using the xml-stylesheet processing instruction.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
steweAuthor Commented:

I've tried it, but the same occurs.
I've MSIE 6.0 installed, and the client and the server are the same.

What is scripted transforms and how can I use it ?

  Stewe
0
 
b1xml2Commented:
ahh,

there must two reasons (one or both) why you are encoutering the error.

1. Your XSLT Document has some flaws. remember that just because you can view XSLT documents as XML Documents does not necessarily mean that it is a valid XSLT Documents. XSLT is an XML Dialect designed specifically for transformations.


2. Your default XML Parser for MSIE is 2.0 as you have not chosen to have a FULL install of MSIE 6.0.

example of scripted transforms
==============================
<html>
<head>
<title>Example Of A Scripted Transform</title>
<script language="javascript">
var oXML = new ActiveXObject("Msxml2.DOMDocument.3.0");
var oXSLT = new ActiveXObject("Msxml2.DOMDocument.3.0");
oXML.async = false;
oXSLT.async = false;
oXML.load("xml/data.asp");
oXSLT.load("xslt/data.asp");
window.onload = init;
function init() {
 var szError = "";
 if (oXML.parseError.errorCode != 0) {
  szError += oXML.parseError.reason + "\n";
 }
 if (oXSLT.parseError.errorCode != 0) {
  szError += oXSLT.parseError.reason + "\n";
 }
 if (szError.length != 0) {
  alert("Errors Encountered\n" + szError;
 } else {
  document.all.data.innerHTML = oXML.transformNode(oXSLT);
 }
}
</script>
</head>
<body>
<h1>Introduction To Transformations</h1>
<div id="data"></div>
</body>
</html>
0
 
steweAuthor Commented:
I've tried your example.
Messagebox:
  Errors Encountered
  The download of the specified resource has failed.

userxsl.asp:
/--------------------------
<%@language="JScript"%>
<%
Response.Buffer=true;
Response.Expires=-1;
Response.ContentType="text/xml";
%>
<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
version="1.0">
<xsl:template match="/">
   hello
</xsl:template>
</xsl:stylesheet>
------------------------------/

userxsl.xsl:
/-----------------------------
<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
version="1.0">
<xsl:template match="/">
   hello
</xsl:template>
</xsl:stylesheet>
------------------------------/

When I use userxsl.asp in your code (oXSLT.load), the error occurs. When I use userxsl.xsl, it works correctly.

   Stewe
0
 
b1xml2Commented:
as i said,

please change your asp accordingly.
note where the processing instruction is relative to the asp %>


<%@language="JScript"%>
<%
Response.Buffer= true;
Response.Expires= -1;
Response.ContentType = "text/xml";
%><?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
version="1.0">
<xsl:template match="/">
  hello
</xsl:template>
</xsl:stylesheet>
0
 
b1xml2Commented:
next, you are using XSL and NOT XSLT.
0
 
steweAuthor Commented:
I've used copy-paste. (I did it at previous try)
And the same...

   Stewe
0
 
b1xml2Commented:
LOL!
change namespace and note that

<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
version="1.0">
<xsl:template match="/">
 hello
</xsl:template>
</xsl:stylesheet>
is an invalid XML Document


try this
<%@language="JScript"%>
<%
Response.Buffer=true;
Response.ContentType="text/xml";
//Note where the pi is located.
%><?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 version="1.0">
<xsl:output method="html" encoding="windows-1252" indent="yes" />
<xsl:template match="/">
   hello
</xsl:template>
</xsl:stylesheet>
0
 
steweAuthor Commented:
I've noticed that '>' and simply correct at previous try.
So... after all, it doesn't work.
The same. If I use userxsl.xsl (it's without the plus xsl:output), it works. If I use userxsl.asp, then it doesn't work.
I can send you screenshots, the files, anything you need.

   Stewe
0
 
steweAuthor Commented:
I've changed the points to 300.
0
 
b1xml2Commented:
send the files to b1xml2@yahoo.com
0
 
b1xml2Commented:
Next, how are you calling the ASP page. Hopefully, it should be via the HTTP Protocol wherein the ASP Code is processed and not thru the File Protocol wherein the ASP Code is unparsed and thus results in the XSLT Document being invalid XML.
0
 
steweAuthor Commented:
HTTP. Simply http.
0
 
steweAuthor Commented:

Hmmm.

userxsl.asp header:

---request begin---
GET /CharmWWW/test/userxsl.asp HTTP/1.0
User-Agent: Wget/1.8
Host: charm.stewe2k.hu
Accept: */*
Connection: Keep-Alive
---request end---
HTTP request sent, awaiting response... HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Wed, 12 Jun 2002 10:45:43 GMT
Connection: keep-alive
Connection: Keep-Alive
Content-Length: 198
Content-Type: text/xml
Expires: Wed, 12 Jun 2002 10:44:43 GMT
Cache-control: private

userxsl.xsl header:

---request begin---
GET /CharmWWW/test/userxsl.xsl HTTP/1.0
User-Agent: Wget/1.8
Host: charm.stewe2k.hu
Accept: */*
Connection: Keep-Alive
---request end---
HTTP request sent, awaiting response... HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Connection: keep-alive
Date: Wed, 12 Jun 2002 10:45:37 GMT
Content-Type: text/xml
Accept-Ranges: bytes
Last-Modified: Wed, 12 Jun 2002 10:45:30 GMT
ETag: "a07b9245fe11c21:bc7"
Content-Length: 198

Differences:
- in asp header, there're 2 Connection: keep alive line
- in xsl header, there are:
    - accept-ranges
    - last-modified
    - etag

What do they mean ?

   Stewe
0
 
steweAuthor Commented:

We cannot solve the problem...

  Stewe
0
 
steweAuthor Commented:

I've solved the problem already, but you're right.
The problem was:
I MUST CHECK 'CACHE ASP' !!!!
Without caching, an error occured while asp generated the xsl. With caching, it simply works.
Try it. Although I give you these points :)

   Stewe
0
 
crw030Commented:
Stewe.

Thanks so much for the points.  Don't know what I did tho.

c
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.