BizTalk Utilities CV ,   Jobs ,   Code library  
 
 

Washington, September 15-18, 1999 – London, November 21-24, 1999

 

The presentation assumes you're familiar with XML and XSL.

Writing Dynamic XML Pages

Dino Esposito

The beauty of XML is that it lets you concentrate on the data side of a project, and allows you to create specialized tags that better suit the domain of a problem. An XML-derived language can accept all and only the tags you list in your definition file, and as a result, you have a specialized language to describe your own data. So our data has a logical structure - but how are we to display this data?

An XML document is just data and needs some kind of rendering in order to be presented in a user-friendly way. So far XML articles and applications have emphasized the role of the markup language to store and analyze pieces of data either on the client or the server-side. You could embed some XML code in regular HTML pages (through data islands) or you could read and manipulate XML strings from within, say, an ASP page. This is already a useful and cutting-edge solution, however you can do much more with XML and Internet Explorer 5.0. Let's see how extensible stylesheets (XSL) can take an XML source file and transform it into a viewable HTML page. After looking at XSL, I'll demonstrate how this machinery could be moved to the server-side and involve ASP pages.

Dino Esposito
Dino (desposito@artis.net) is a trainer and consultant based in Rome, Italy. He specializes in Windows and scripting and authored Visual C++ Windows Shell Programming and Windows Scripting Host Programmer's Reference both from Wrox Press. Dino is also a contributing editor to Microsoft Internet Developer, MSJ and MSDN News. He's the cofounder of www.vb2themax.com, a VB-oriented Web site and works for Artis srl, a Rome-based consulting company active in the system integration area and Web-based architectures.

You probably know a lot about HTML pages created dynamically on the server and then served up to the browser - this is what ASP technology makes possible. A drawback with this is that the basic language is still HTML and you still use HTML to describe your data and the way it must be rendered. You should also know a lot about how XML lets you separate data and presentation. Why not then write dynamic XML Pages? That is, ASP pages that produce XML/XSL output to be read by an XML-compliant browser like IE5. If you think that this limits you and your users to having IE5 as the browser, then don't worry. I'll also demonstrate how you can have other browsers, such as Netscape Communicator, to manage them as pure HTML. What's your ultimate gain? You design and code your ASP pages (and possibly your Web site) using the more expressive XML instead of HTML.

XML, XSL and ASP: What's Common?

There's a subtle resemblance between XML/XSL and ASP/HTML. ASP is a template page based on HTML that contains expandable blocks of code. The parser analyzes them and sends out pure HTML code to the browser. This code has been generated on the fly and doesn’t belong to a static HTML page.

On the other hand, XML is a generic and tagged description of a document. You can tie any of those tags to a certain block of HTML code with XSL. XSL is conceptually similar to ASP in the way that it takes an HTML-based template file and expands some tags reading input data from the associated XML document.

The idea being that, since we have a browser like IE5 that understands pure XML and provides direct browsing functionality (XSL support) why not write ASP pages based on XML instead of HTML? If you can afford an XML-compliant browser then you have a double advantage:

Ø        You use the more expressive XML rather HTML to design your pages

Ø        You have dynamic XML pages. (I call these XSP, XML Server Pages)

Using browsers that only understand HTML, you can still refer to XML-based ASP pages but you need to make the conversion from XML to HTML on the server. This is possible but makes the page less dynamic since you don’t have the result of ASP processing as a separate stream of bytes - the final XML page that ASP returns to the browser is never explicitly available to server-side XSL processing.

However, passing from ASP also lets you use static XML pages with Netscape and IE4. The XSL is applied in the background using the IE5 XML object model assuming, of course, that the required IE5 components are present on the server.

Using XML Through the Web

The combination XML+XSL+ASP is particularly useful for small applications built around a certain data type. You could design an XML-based language to manage those objects (objects taken from the domain of the problem, for example car descriptions, car information queries). This language can be identified by a DTD document.

Next, the XSL tells the browser how to manage those customized tags to produce HTML and actually display the document.

Notice that at this point, you have a logical, well-formed set of tags for your domain. Any file compatible with that grammar can be displayed using a specific template. If you need a completely different view, you don’t need to change the XML descriptive data, but just the template. This may remind you of the MFC and SmallTalk document/view model.

The Example

You can write ASP pages using XML instead of HTML tags very easily: simply change the XML file extension to ASP and move it to a directory on your Web server. Since now the XML source code is an ASP page, you can add ASP <%…%> blocks within it. Be aware, of course, that the final output is XML-compliant. For example, this is a perfectly valid code:

<COVER

   title=<%=Request("Title")%>

   subtitle="What Every Web Developer Needs to Know">

</COVER>

and nothing prevents you from navigating to a URL like this:

http://expoware/xml/mind0399.asp?Title="Win2K"

Supporting Other Browsers

Since ASP is server-side technology, you might think that the hard work is over, and that any browser can now support XML direct browsing! Unfortunately, this is untrue. DTD validation and direct browsing are steps that take place on the client side, so even if you've been able to create dynamic XML files, you'll still need a browser capable of XSL processing, and today, the only browser that's capable of this is IE 5.0. However, just the possibility of using ASP code as well as the presence of a powerful XML object model is an exciting prospect.

To get around the problem of compatibility, you should write your XML-based ASP pages with a special heading that can work around the browser's differences:

<%

  uAgent = Request.ServerVariables("HTTP_USER_AGENT")

  if Instr(uAgent, "MSIE 5.0") <= 0 then

    ' 1. Transform XML code into HTML exploiting any XML

    ' engine on the server that knows how to handle XSL.

    ' (e.g. IE5)

    ' 2. Response.Write the HTML code produced

    Response.End

  end if

%>

This is not a definitive solution since it forces you to return to <%…%> code. While this is a significant loss, you can still use XML to design the pages. In this way, browsers such as Netscape can understand XML, but only as static pages.


 

Recent Jobs

A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En
A Greate Opportunituy as a SQL Deve
An immediate job opportunity as a B

View all Jobs (Add yours)
View all CV (Add yours)



chicago web site design
spfxmasks
Host Department NOLIMIT Web Hosting
.co.uk Domain Names
Gucci sunglasses
NY Pool Contractor
answering service
conference calling
swimming pool builder
MSN
sunglasses


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP