WebDeveloper.com �: Where Web Developers and Designers Learn How to Build Web Sites, Program in Java and JavaScript, and More!   
Web Developer Resource Directory WebDev Jobs
Animated GIFs
CSS Properties
HTML 4.01 Tags
Site Management
WD Forums

    Web Video
    Expression Web



    Forum, Blog, Wiki & CMS

 Site Management
    Domain Names
    Search Engines
    Website Reviews

 Web Development
  Business Issues

    Business Matters

    The Coffee Lounge
    Computer Issues

XML Does It Your Way!
Part 2

by Scott Clark


So your choice is now between using an ActiveX component or a built-in Java applet XML parser. There isn't a whole lot of documentation available concerning the proprietary parameters the Java parser applet uses, but you can make it work for your purposes by looking at Microsoft's examples. If you're into Java programming, download the latest version of the parser from here; it includes a set of documents which describes the classes and methods that comprise the public API for the XML Parser.

The ActiveX XML Parser

The ActiveX component uses an XSL file for its formatting guidelines. As it stands now, the ActiveX XML parser works very well, however the creation of the XSL style sheets is another story. Essentially, XSL uses formatting parameters called "construction rules" to describe how an element is formatted into its eventual form which is displayed in the Web browser (or other display). Each construction rule is made up of two parts. The first is a pattern which identifies the type of XML source element; the second is an action which describes what the parser should do with the elements that match the above pattern.

Without going into our own XSL tutorial, suffice it to say that you'll have to learn how to code XSL files for your own use. Don't feel overwhelmed, though, as XSL is actually a form of XML code anyway, so you won't have two languages to learn.

Additionally, CSS (Cascading Style Sheets) may also be used to control the display of XML documents, however XSL is more extensible, as it can use scripts, flow object macros (which are yet to be implemented) and extensible flow object types (which are also not yet implemented). CSS basically maps each XML element into a single display object using certain display characteristics. Using XSL instead of CSS enables us to use the same XML elements to display the data using many different characteristics.

Our XML Example Page [Note: this example only works for MSIE4; see the Netscape specific example to see the MS Java parser in action.] uses the following XSL code to format the XML document using the ActiveX control (the Java version is directly below the ActiveX version so you can compare the two):

 <xsl> <rule> <root/> <HTML> <BODY font-family="Arial, helvetica, sans-serif" font-size="12pt" background-color="#EEEEEE"> <children/> </BODY> </HTML> </rule> <rule> <target-element type="TOPIC"/> <DIV background-color="lightblue" color="blue" padding="4px"> Title: <select-elements> <target-element type="TITLE"/> </select-elements>; Author: <select-elements> <target-element type="AUTHOR"/> </select-elements> </DIV> <DIV margin-left="20px" margin-bottom="1em" font-size="10pt"> Publisher: <select-elements> <target-element type="PUBLISHER"/> </select-elements>; <select-elements> <target-element type="PAGES"/> </select-elements> pages; Price: <select-elements> <target-element type="PRICE"/> </select-elements> </DIV> </rule> </xsl> 
The ActiveX XML parser is pointed to this file using a parameter in the OBJECT tag (HTML):

<PARAM NAME="styleURL" VALUE="article.xsl">

[ < XML Does It Your Way!:
Part 1 (So Tell Me About It!) ]
[ XML Does It Your Way!:
Part 3 (ActiveX for the Masses) > ]

HTML5 Development Center

Recent Articles