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:

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:

  1. Build the example
  2. Configure the WebLogic server
  3. Run the example

Build the example

  1. Set up your development shell as described in Setting up your environment.

  2. 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.

  3. 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:

    1. Compiles the Client.
    2. Runs the parser generator against the slideshow.dtd to generate a custom parser.
    3. Compiles the RequestHandler class into the WEB-INF/classes directory of the examples Web application directory.
    4. Copies the slideshow.dtd file into the XML registry directory.
    5. Copies the Generated_parser.jsp file into the examples Web application directory.
    6. Compiles the JSP Generated_parser.jsp into the WEB-INF\classes directory of the examples Web application directory.

Configure the Server

This procedure shows how to use the Administration Console of the WebLogic server to specify a customized parser for a particular document type.

  1. Start the WebLogic server with the e xamples configuration in a new command shell.
  2. Invoke the Administration Console in your browser.
  3. Click to expand the Services node in the left-hand pane.
  4. Click to expand the XML node in the left-hand pane.
  5. Click the examplesXMLRegistry node.
  6. Right-click the XML Parser Select Registry Entry node and chose Configure a New XMLParserSelectRegistryEntry from the drop-down list.
  7. Enter -//BEA Systems, Inc.//DTD for slideshow//EN in the Public Id field.
  8. Enter examples.xml.generatedParser.SlideParser in the Parser Class Name field.
  9. Click Create.
  10. Click the examplesServer node under the Server node in the left pane.
  11. Click the Services tab.
  12. Click the XML tab.
  13. Make sure that you have selected examplesXMLRegistry as the XML registry that is associated with the examplesServer server in the XML Registry field.
  14. Click Apply.

Run the Example

  1. Start the WebLogic Server in a new command shell.

  2. 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:


Documentation is available at
http://e-docs.bea.com/wls/docs61

Copyright © 2001 BEA Systems, Inc. All Rights Reserved.