TOC PREV NEXT INDEX




Rendering XML Documents



An XML document contains data, but does not contain information about how that data should be displayed. That information is in an associated stylesheet.

  1. If an XML document is associated with a CSS2 type stylesheet, your application can parse and render it without any additional libraries.
  2. To render an XML document associated with an XSLT stylesheet, you need to include additional libraries on the classpath. Include the ib6xalan.jar so that the Xalan module can perform the XSL transformations. Also include the xalan.jar and possibly the xml-apis.jar, depending on what version of Xalan you download from http://xml.apache.org/.
You also must make a static call to the DOM to set the Transformer Factory:
DOM.setTransformFactory( stormBase, transformFactory ); 
 
This call ensures that the core classes will correctly handle XSL transformations.
  1. If an XML document is not associated with either a CSS2 or XSLT stylesheet, it may optionally be displayed in the browser as a Document Tree. In this case, the HTML4 pilot internally converts the XML document into an HTML document suitable for display and navigation in the browser. To enable the automatic conversion of XML documents to a Document Tree in the HTML4 Pilot, the following system property must be defined:
    ice.pilots.html4.viewXmlAsTree=true
     
    
Note: An XML document will also be displayed as a Document Tree if it references an XSLT stylesheet and support for the optional Xalan XSL transformation engine is not configured.
XML Examples
XML Parser

For information on how to use the browser component as an XML parser without instantiating any graphical objects, see the example Parser.java, described in Example Files.

XML Document With CSS File

The following example (t1.xml) shows an XML document with corresponding CSS file.

<?xml-stylesheet href="t1style.css" type="text/css"?>

<docu>

<heading>XML rendering test</heading>

<para>This test demonstrates the ability of ICEbrowser to display

arbitrary XML data with CSS2 stylesheets.</para>

<para>Starting with the final release of 5.0, ICEbrowser supports

the XML/stylesheet linking recommendation from W3C.</para>

<para>A shortcut: There is no DTD support for XML (for now)

so you must make sure that all the tags are opened and closed

correctly.</para>

<para>Just for fun: <red>This text is red, move mouse over

it</red></para>

</docu>
 

The CSS (t1style.css) tells the browser how to display the page:

docu {display: block; padding: 10px;}

heading, 

para {display: block; margin: 20px 0px;}

para:hover {outline: 4px solid black;}

red {color: white; background-color: red;}

red:hover {background-color: blue; outline: 2px solid green;}

heading {font-weight: bold; font-size: 2em; text-align: center;}

bold {font-weight: bold;}
 


Copyright 2005. ICEsoft Technologies, Inc.
http://www.icesoft.com

TOC PREV NEXT INDEX