Oracle8i Application Developer's Guide - XML Release 3 (8.1.7) Part Number A86030-01 |
Library | Service | Contents | Index

Using XSQL Servlet, 18 of 24

## Using the XSQL Page Processor Programmatically

`oracle.xml.xsql.XSQLRequest`() class uses the XSQL Page Processor from your Java programs.

For example:

    import oracle.xml.xsql.XSQLRequest;

        import java.util.Hashtable;
        import java.io.PrintWriter;
        import java.net.URL;
        public class XSQLRequestSample {
          public static void main( String[] args) throws Exception {
            // Construct the URL of the XSQL Page
            URL pageUrl = new URL("file:///C:/foo/bar.xsql");
            // Construct a new XSQL Page request
            XSQLRequest req = new XSQLRequest(pageUrl);
            // Setup a Hashtable of named parameters to pass to the request
            Hashtable params = new Hashtable(3);
            params.put("param1","value1");
            params.put("param2","value2");
            /* If needed, treat an existing, in-memory XMLDocument as if
    ** it were posted to the XSQL Page as part of the request

Example:

req.setPostedDocument(myXMLDocument);

            **
            */

            // Process the page, passing the parameters and writing the output
            // to standard out.
            req.process(params,new PrintWriter(System.out)
                              ,new PrintWriter(System.err));
          }
        }

You can also call `processToXML()`instead of `process()` to return the XML Document in-memory that results from processing the XSQL Page requested and applying any associated XSLT Transformation.

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index