Solved

ASP generated XSL

Posted on 2002-06-11
19
417 Views
Last Modified: 2008-02-01

  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
0
Comment
Question by:stewe
  • 9
  • 8
  • 2
19 Comments
 
LVL 23

Expert Comment

by:b1xml2
ID: 7069953
<%@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
 
LVL 23

Expert Comment

by:b1xml2
ID: 7069980
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
 
LVL 1

Author Comment

by:stewe
ID: 7070131

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
 
LVL 23

Expert Comment

by:b1xml2
ID: 7070184
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
 
LVL 1

Author Comment

by:stewe
ID: 7070236
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
 
LVL 23

Expert Comment

by:b1xml2
ID: 7070304
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
 
LVL 23

Expert Comment

by:b1xml2
ID: 7070317
next, you are using XSL and NOT XSLT.
0
 
LVL 1

Author Comment

by:stewe
ID: 7070428
I've used copy-paste. (I did it at previous try)
And the same...

   Stewe
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7070456
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 1

Author Comment

by:stewe
ID: 7070500
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
 
LVL 1

Author Comment

by:stewe
ID: 7070544
I've changed the points to 300.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7070559
send the files to b1xml2@yahoo.com
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7071910
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
 
LVL 1

Author Comment

by:stewe
ID: 7072229
HTTP. Simply http.
0
 
LVL 1

Author Comment

by:stewe
ID: 7072443

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
 
LVL 1

Author Comment

by:stewe
ID: 7072664

We cannot solve the problem...

  Stewe
0
 
LVL 1

Accepted Solution

by:
crw030 earned 300 total points
ID: 7234646
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
 
LVL 1

Author Comment

by:stewe
ID: 7235512

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
 
LVL 1

Expert Comment

by:crw030
ID: 7236474
Stewe.

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

c
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now