|
|
| WebLogic Server 6.1 Code Examples, BEA Systems, Inc. |
Package examples.xml.generatedParser
This example demonstrates how to generate a customized parser for a specific DTD and then parse an XML document described by the DTD using the generated parser obtained via JAXP.
See:
Description
|
Class Summary |
| RequestHandler |
This class extends HandlerBase and is used to handle events
created as an XML document is parsed by a SAX compliant
parser. |
Package examples.xml.generatedParser Description
This example demonstrates how to generate a customized parser for a specific DTD and then parse an XML document described by the DTD using the generated parser obtained via JAXP.
In the example, the JSP Generated_parser.jsp receives an XML file over HTTP from a Client and uses the generated parser to parse the document.
You must configure the WebLogic server to use the generated parser by specifying
in the Administration Console which document types use the parser. Instructions
for doing this are included below.
The example illustrates how to:
- read an XML file and write it to an output stream.
- configure the WebLogic server to use a customized parser for a particular
XML document type.
- validate and parse XML data using a customized parser for a specific DTD.
- pass XML data between a client and a JSP via an HTTP POST.
|
Additional Resources for examples.xml.generatedParser |
| Generated_parser.jsp |
The JSP that receives the XML data from the Java Client, parses it, and sends an acknowledgement back to the Client over HTTP. |
| slideshow.xml |
The XML file passed between the Java Client and the JSP over HTTP. |
The following section describes how to build and run the example:
- Build the example
- Configure the WebLogic server
- Run the example
- Set up your development shell as described in
Setting up your environment.
- Add the xmlx.jar file,
located in the %WL_HOME%\lib
directory, to your CLASSPATH.
%WL_HOME% refers to
the directory in which you installed the WebLogic server.
- Compile the example by executing the Java ant command.
The Java ant command uses the
build.xml file, located in the samples/examples/xml/generatedparser
directory, to build the example. The Java Ant command performs the following steps:
- Compiles the Client.
- Runs the parser generator against the slideshow.dtd to generate a custom parser.
- Compiles the RequestHandler class into the WEB-INF/classes directory of the examples Web application directory.
- Copies the slideshow.dtd file into the XML registry directory.
- Copies the Generated_parser.jsp file into the examples Web application directory.
- Compiles the JSP Generated_parser.jsp into the WEB-INF\classes directory of the examples Web application directory.
This procedure shows how to use the Administration Console of the WebLogic
server to specify a customized parser for a particular document type.
- Start the WebLogic server with the e
xamples
configuration in a new command shell.
- Invoke the Administration Console in
your browser.
- Click to expand the Services node in the left-hand pane.
- Click to expand the XML node in the left-hand pane.
- Click the examplesXMLRegistry node.
- Right-click the XML Parser Select Registry Entry node and chose Configure a New XMLParserSelectRegistryEntry from the drop-down list.
- Enter -//BEA Systems, Inc.//DTD for slideshow//EN in the Public Id field.
- Enter examples.xml.generatedParser.SlideParser in the Parser Class Name field.
- Click Create.
- Click the examplesServer node under the Server node in the left pane.
- Click the Services tab.
- Click the XML tab.
- Make sure that you have selected examplesXMLRegistry as the XML registry that is
associated with the examplesServer server in the XML Registry field.
- Click Apply.
Run the Example
- Start the WebLogic Server in a new command shell.
- In your development shell, run the Client with the following command:
$ java examples.xml.Client http://hostname:port/examplesWebApp/Generated_parser.jsp slideshow.xml
where:
- hostname
- Host name of the WebLogic Server.
- port
- Port where the WebLogic Server is listening for connections
(weblogic.system.ListenPort).
There's More...
Read more about:
Copyright © 2001 BEA Systems, Inc. All Rights Reserved.