XML Technology
Samples for Java
Two samples
are supplied with this release to illustrate some basic capabilities
of XML parsing and stylesheet processing with Java. In particular, they
illustrate the functioning of the following components in this kit:
- XML
parsing in Java
- XSLT
translation in Java
Sample
1
Sample 1 demonstrates
XML execution on the client side, using an XML-capable browser (Internet
Explorer 5 or later). The source code (XML and JavaScript) resides on the OpenVMS server,
and it is parsed by the XML utilities provided by IE5.
Sample
2
Sample 2 demonstrates XML
execution on the server side, meaning it is not browser-dependent. The
source code is processed on the OpenVMS server, which requires the .JAR
files. Otherwise, the browser will report an error initiated from the
JavaScript.
Sample 1:
Data Entry Page
The
Data Entry Page is an HTML file containing XML and JavaScript. You can
enter information in a form and see that information displayed as HTML.
Processing of the XML and script is handled by the client browser.
To try,
simply open a client browser and point to the appropriate URL on your
OpenVMS server:
samples/ex01/bookclient.htm
For example:
http://<yourserver>/xmltech/samples/ex01/
bookclient.htm
The following
schematic illustrates the order in which XML files are typically processed
and executed:

Sample 2:
XML-HTML Transform
This sample
transforms XML into HTML using an XSLT stylesheet. You specify an XML
source file, and using the supplied W3 stylesheet see a formatted HTML
page generated from the source.
Instructions
These instructions assume you have installed Compaq Secure
Web Server (or Compaq's Apache Web Server).
- Create
a samples directory under HTDOCS.
Set security
on HTDOCS and the samples directory to:
$ SET SECURITY/OWNER=APACHE$WWW
- Copy
both .JAR files (XERCES.JAR and XALAN.JAR) to the samples directory.
- Open
a PC client browser on your local intranet, either Internet Explorer
or Netscape Navigator.
Make
sure that you are using default security and Java settings. For example,
in IE 5.5, do the following:
- From
the Tools menu, choose Internet Options.
- In
the Internet Options dialog box, select the Security
tab, and click Default Level while Local
Intranet is selected.
- Select
the Advanced tab, and click the Restore
Defaults button.
- Click
OK to close the dialog box.
- Close
all browser windows to make sure that the cached settings are replaced.
- Open
a new browser window and point to the appropriate URL on your OpenVMS
server:
/samples/ex02/_xml_to_html.htm
For example:
http://<yourserver>/xmltech/samples/ex02/_xml_to_html.htm
- Select
either XML file from the drop-down list (xml_hello.xml or xml_xalan_xerces.xml).
- Select
either HTML or HTML Source, and
click the Transform button.
You may
have to wait several seconds the first time you click Transform, during
which time your browser will appear frozen. Wait till you see either
the rendered HTML or the source HTML as generated from the XML. The
parsing and translation components are both exercised, processing
the XML and applying an XSLT stylesheet to generate the HTML.

The following
schematic illustrates the order in which files are processed and executed
for this example:

Viewing
the Java Console
The Java
console lets you see errors, if any, in the Java-JAR-XML processing.
Instructions
for Netscape Communicator
- Open
the Java console by choosing Tools from the Communicator
menu and Java Console from the Tools
menu.
On opening
the _xml_to_html.htm page, the Java console should show the following
text if there are no errors:
Netscape Communications Corporation
-- Java 1.1.5
Type '?' for options.
Symantec Java! ByteCode Compiler Version 210.065
Copyright (C) 1996-97 Symantec Corporation
Primed the pump!
Instructions
for Internet Explorer
- Enable
the Java console by choosing Internet Options from
the Tools menu and click the Advanced
tab.
- Scroll
down to the Java VM section and select the Java
console enabled option. Click OK.
- From
the View menu choose Java Console
to open the window.
On opening
the _xml_to_html.htm page, the Java console should show the following
text if there are no errors:
Microsoft (R) VM for Java, 5.0
Release 5.0.0.3176
==============================================
? help
c clear
f run finalizers
g garbage collect
m memory usage
q quit
t thread list
==============================================
Primed the pump!
Errors
such as not finding the .JAR files will produce verbose error messages.