Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP/XML/XSL any advantage?

Posted on 2004-11-04
6
Medium Priority
?
273 Views
Last Modified: 2006-11-17
Hi

We are into the maintenance of  web application. It is an intranet applciation. The details are as follows
Backend : SQL server 2000
Front end : ASP/ XML/ XSL

ASP pages initiates the execution of the SPs to get the data into a recordset. Then by running a 'While' loop, an XML file is created for that data from the recordset. The XML file is then presented using an XSL file. XML file contains tags for different properties of each component like 'on click even' , 'on mouse over', 'text' , visibility' , type of the compoentn - whether it is a text box/ button etc

The screeens are extremely slow. The databse is quite big and growing fast. But the indexes are properly defined, so I dont think the data retreival is taking much time. I tried to execute the SPs independantly and it is fast.

The screens are very heavy with a lot of controls - which includes lists, data entry compoennts, radio buttons, buttons etc. The server is in the local network.

Does any one know whether the XML creation and presentation using XSL is a time consuming process or not.

What is the best way of creating dynamic pages in asp?

Does the methodology of using the XML/XSL is of any benefit?

Thanks

Binny





0
Comment
Question by:binsaji
  • 3
4 Comments
 
LVL 15

Accepted Solution

by:
deighc earned 100 total points
ID: 12502873
XSL transformations with MSXML are very fast so long as you use the newer versions of the XML parser. Compared to XML parsers on any other platform MSXML is a rocketship.

You say that your data access is fast. So you can rule that out of the equation.

It's possible that, if you're rendering control-rich HTML pages, that the page rendering time is a bit of an issue. But I think that this is unlikely. Most half-decent modern computers can display web pages pretty quickley even if they are complex and feature lots of controls.

The most likely culprit in my opinion is the bit in the middle: looping thru your data and building up the XML document.

How do you this?
Do you build up a string and load this into the XML DOM (this would VERY slow, unless you used a string buffer - in which case it would slow-ish)?
Do you programmatically build an XML DOM (this could be OK performance wise - depends how you do it - but still not great)??

The absolute quickest way to dump recordset data into an XML DOM is to use the .Save method of the recordset and specify an XML DOM object as the target. This is VERY fast (because you're using native ADO functionality) but you end up with XML that has a very flat structure (although you do get a nice schema section that describes all the fields in your recordset). Code is very simple:

rsObj.Save xmlDOMObj, adPersistXML (adPersistXML is a constant with a value of 1)

This streams the recordset data from rsObj into and XML DOM xmlDOMObj in XML format (as specified in the second argument of .Save method).

But it's likely that you won't want re-write all your XSL templates to work of the new XML source data. So one thing you could think about doing is an initial transformation to change your recordset sourced XML into XML of the same format you're using now. This would still be alot quicker than other ways of building up your source XML.

But either way, it's a bit of work for you.
0
 
LVL 15

Expert Comment

by:deighc
ID: 12502895
> What is the best way of creating dynamic pages in asp?

> Does the methodology of using the XML/XSL is of any benefit?

...and to answer this bit: XML/XSL is a perfectly viable way to generate dynamic pages in ASP. I built a few ASP web app's that use it and, with a bit of care and planning, the performance and functionality is good.

I love XSL. It's standards based and works well. I can my XSL knowledge with ASP, PHP, Java - whatever. So investing time in learning it is time well spent in my opinion.
0
 
LVL 9

Assisted Solution

by:AlfaNoMore
AlfaNoMore earned 100 total points
ID: 12503436
You should use the "FOR XML EXPLICIT" syntax that SQL Server 2000 provides. Have a look here: http://www.topxml.com/sql/for_xml_explicit.asp

It's a bit confusing at first, but will output XML in the format you require. rather than asking ADO to automatically save the Recordset as XML (often a bit nasty XML!), or doing this via a Recordeset, just stream waht you want direct from SQL.

Assuming you go down this route, you'll need to get the XML streamed from sql, so you'll need an ADO command object:

Set ConnClass      = New DatabaseConnection      
Set objStream      = Server.CreateObject("ADODB.Stream")
Set objCmd      = Server.CreateObject("ADODB.Command")
Set objSQLXML      = Server.CreateObject("MSXML2.DOMDocument")

objStream.Open
objStream.Charset = "iso-8859-1"
objStream.Type = adTypeText

With objCmd
      .ActiveConnection            = ConnClass.OpenConnection()
      .CommandType                  = adCmdStoredProc
      .CommandText                  = dbObject
      .NamedParameters            = True
            
      .Properties("Output Stream").Value = objStream
                  
      For Each strParam In oParams
            .Parameters.Append .CreateParameter(strParam, adInteger, adParamInput, 4, oParams(strParam))
      Next
            
      .Execute, , adExecuteStream
End With
            
objStream.Position = 0
            
If 0 Then
      Response.Clear()
      Response.Charset = "windows-1252"
      Response.ContentType = "text/xml"
      Response.Write(objStream.ReadText)
      Response.End()
End If
            
objSQLXML.LoadXML(objStream.ReadText)
Set getXMLfromSQL = objSQLXML.documentElement
objStream.Close()
      
Set objParameter      = Nothing
Set objCmd      = Nothing
Set objStream      = Nothing
Set ConnClass      = Nothing


0
 
LVL 15

Expert Comment

by:deighc
ID: 12504373
It's true that the FOR XML directive in SQL Server gives you a nicer XML output, and the performance is good too.

But I don't like it because it means that you can only use those SP's for outputting XML. It means duplicating your query logic if you need both XML'ised data and recordset objects from your database.

But depending on your exact requirements this is definitely another option.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

804 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