ASP/XML/XSL any advantage?

Posted on 2004-11-04
Last Modified: 2006-11-17

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?



Question by:binsaji
    LVL 15

    Accepted Solution

    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.
    LVL 15

    Expert Comment

    > 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.
    LVL 9

    Assisted Solution

    You should use the "FOR XML EXPLICIT" syntax that SQL Server 2000 provides. Have a look here:

    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.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))
          .Execute, , adExecuteStream
    End With
    objStream.Position = 0
    If 0 Then
          Response.Charset = "windows-1252"
          Response.ContentType = "text/xml"
    End If
    Set getXMLfromSQL = objSQLXML.documentElement
    Set objParameter      = Nothing
    Set objCmd      = Nothing
    Set objStream      = Nothing
    Set ConnClass      = Nothing

    LVL 15

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    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

    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…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now