Solved

ASP - XML,XSL

Posted on 2002-06-12
4
336 Views
Last Modified: 2008-02-01

  Hi !

I need an exact way how to generate dinamically XML,XSL from ASP.

Prob:
When I use native .xml and .xsl and view it in a browser, it works correctly.
When one of them (or both) comes from ASP, *sometimes* generates an error.

F.e. xsl-asp:
<%@language="JScript"%>
<%
Response.Buffer= true;
Response.ContentType = "text/xml";
%><?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>

F.e. xml-asp:
<%@language="JScript"%>
<%
Response.Buffer= true;
Response.ContentType="text/xml";
%>
<?xml version="1.0" encoding="windows-1252"?>
<data>
     <User Active="1" UserName="Stewe"/>
</data>

It's not a real dinamic xsl, xml, but just for an example. Sometimes it doesn't work. Error f.e.: Xml document must have a top - level element.
I've tried it with script transform, but the same occurs.

When I load first the ASP-XML part, then the native XSL part, so then sometimes ASP-XML generates an error.
When I use both of them as ASP, then sometimes the first, sometime the last generates the error. SOMETIMES.

script transform:
var oXML = new ActiveXObject("Msxml2.DOMDocument.3.0");
var oXSLT = new ActiveXObject("Msxml2.DOMDocument.3.0");
oXML.async = false;
oXSLT.async = false;
oXSLT.load("userxsl.asp"); // or userxsl.xsl
oXML.load("user.asp"); // or user.xml

I cannot found a stabile way.
When both of them are native, then everything is stabile and working correctly.

There're differences in ASP-XSL and native XSL header.

Only in native XSL header (f.e. GET localhost/userxsl.xsl)
ETag: "a07b9245fe11c21:bc7"
Accept-Ranges: bytes
Last-Modified: Wed, 12 Jun 2002 10:45:30 GMT

Only in ASP-XSL header:
Connection: keep-alive
Connection: Keep-Alive (native XSL has only the first one)
Cache-control: private
Expires: Wed, 12 Jun 2002 10:44:43 GMT

Both content type is text/xml of course.

What can be the problem.
I've just updated everything using windows update. Everything.


   Stewe

0
Comment
Question by:stewe
  • 2
  • 2
4 Comments
 
LVL 23

Expert Comment

by:b1xml2
ID: 7073397
The answer is this stewe.

consider this
=============
XSLT Document
==============
<%@language="JScript"%>



<%
Response.Buffer= true;
Response.ContentType = "text/xml";
%>
<?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>


There will be an error generated by the XSLT Engine indicating that the stylesheet is not well-formed. Viewing it directly will pose no problem. This is a legacy of MSXML 2 where if there is an empty line at the top of the document, it wont load for any XML document. So, view the xsl.asp source and see if there is an extra line at the top.

If the asp is changed to
<%@language="JScript"%>
<%
Response.Buffer= true;
Response.ContentType = "text/xml";
%><?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>


There will be no problem.

Make sure you clear your cache before you do anything with your browser.
0
 
LVL 23

Accepted Solution

by:
b1xml2 earned 300 total points
ID: 7073404
also you might like to do the same for your XML document.

<%@language="JScript"%>
<%
Response.Buffer= true;
Response.ContentType="text/xml";
%><?xml version="1.0" encoding="windows-1252"?>
<data>
    <User Active="1" UserName="Stewe"/>
</data>
0
 
LVL 1

Author Comment

by:stewe
ID: 7074969

You're ok. It works now.
There're 2 important things:
- these new lines
- and in IIS, the 'ASP file caching' MUST BE CHECKED. MUST BE.

   Stewe
0
 
LVL 1

Author Comment

by:stewe
ID: 7074972
Thx

   Stewe
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Nessus Scan 1 68
Getting lots of W3C errors in my XHTML site... 43 68
Path of Workbook 3 59
Help with a If commands in MS word 2010 when using with a XML drop down box 5 26
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

15 Experts available now in Live!

Get 1:1 Help Now