Skip Headers

Oracle® XML Developer's Kit Programmer's Guide
10g Release 1 (10.1)

Part Number B10794-01
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Master Index
Master Index
Go to Feedback page

Go to previous page
Go to next page
View PDF

9 Pipeline Definition Language for Java

This chapter contains these topics:

Using Pipeline Definition Language

XML Pipeline definition Language from W3C, enables you to describe the processing relations between XML resources. A pipeline document specifies input and output of processes. A pipeline controller uses the pipeline document to execute the specified processes.

Oracle XML Pipeline Processor is built upon the XML Pipeline Definition Language Version 1.0, W3C Note 28 February 2002. The processor can take an input XML pipeline document and execute the pipeline processes according to the derived dependencies. The pipeline document is an XML document, and specifies the processes to be executed in a declarative manner. In addition to the XML Pipeline Processor, the XDK defines several Pipeline Processes which can be piped together in a pipeline document.

There are some differences between the W3C Note and the Oracle implementation. They are:

The Pipeline Definition Language is described at:

Example of a Pipeline Definition Language Application

The files for this example are in /xdk/demo/java.101/pipeline/. The application calls the pipeline document (an instance of the Pipeline Definition Language) named pipedoc.xml, which names book.xsl as the stylesheet to be used, myresult.html as the output HTML file, and book.xml as the XML document to be parsed. The processes are p2, p3, and p1 in the order given in pipedoc.xml. However, the processes are run in the order p1, p2, p3.

To run this example:

  1. Add xmlparserv2.jar and the current directory to the CLASSPATH.

  2. Use make to generate .class files.

  3. Run the sample program:

    make demo

    Or run:

    java PipelineSample pipedoc.xml pipelog seq

    The first argument (pipedoc.xml) is the required pipeline document. pipelog is an optional log file that you name. If omitted, the default log file created is pipeline.log.

    seq can be either "para" or "seq", entered without the quotes. "seq" requests sequential processing. If omitted, the default mode is processing parallel threads, the same mode as if you entered "para".

  4. View the pipeline target created, in this case myresult.html.

The error handler called by the Java program is

Here is book.xml, the input XML document with which you started the processing:

<?xml version="1.0"?>
    <title>Twelve Red Herrings</title>
    <author>Jeffrey Archer</author>
    <publisher>Harper Collins</publisher>
    <title language="English">The Eleventh Commandment</title>
    <author>Jeffrey Archer</author>
    <publisher>McGraw Hill</publisher>   
    <title language="English" country="USA">C++ Primer</title>
    <publisher>Harper Collins</publisher>   
    <title>Emperor's New Mind</title>
    <author>Roger Penrose</author>
    <publisher>Oxford Publishing Company</publisher>
    <title>Evening News</title>
    <author>Arthur Hailey</author>
    <publisher>MaMillan Publishers</publisher>

Here is pipedoc.xml, the pipeline document:

<pipeline xmlns=""

  <param name="target" select="myresult.html"/>

  <processdef name="domparser.p" definition="oracle.xml.pipeline.processes.DOMParserProcess"/>
  <processdef name="xslstylesheet.p" definition="oracle.xml.pipeline.processes.XSLStylesheetProcess"/>
  <processdef name="xslprocess.p" definition="oracle.xml.pipeline.processes.XSLProcess"/>

   <process id="p2" type="xslstylesheet.p" ignore-errors="false">
     <input name="xsl" label="book.xsl"/>
     <outparam name="stylesheet" label="xslstyle"/>

   <process id="p3" type="xslprocess.p" ignore-errors="false">
     <param name="stylesheet" label="xslstyle"/>
     <input name="document" label="xmldoc"/>
     <output name="result" label="myresult.html"/>

  <process id="p1" type="domparser.p" ignore-errors="true">
     <input name="xmlsource" label="book.xml "/>
     <output name="dom" label="xmldoc"/>
     <param name="preserveWhitespace" select="true"></param>
     <error name="dom">
       <html xmlns="http://www/w3/org/1999/xhtml">
            <title>DOMParser Failure!</title>
           <h1>Error parsing document</h1>


The stylesheet book.xsl is listed next:

<?xml version="1.0"?> 

<xsl:stylesheet xmlns:xsl="" version="1.0">
  <xsl:output method="xml"/> 

  <xsl:template match="/">
  <!-- document xsl:template -->

  <xsl:template match="booklist">
        <H1>List of books</H1>
        <P> This will illustrate the transformation of an XML file containing
            a list of books to an HTML table form </P>
  <xsl:template match="booklist/book">

  <xsl:template match="booklist/book/title">

  <xsl:template match="booklist/book/author">

  <xsl:template match="booklist/book/publisher">

  <xsl:template match="booklist/book/price">
       Price: $<xsl:apply-templates/>


The output is myresult.html in the /log subdirectory

<?xml version = '1.0'?>
<HTML><HEAD/><BODY BGCOLOR="#CCFFFF"><H1>List of books</H1><P> This will
 illustrate the transformation of an XML file containing list of books to an
 HTML table form </P>
    Twelve Red Herrings
    Jeffrey Archer
       Price: $7.99      
    The Eleventh Commandment
    Jeffrey Archer
       Price: $3.99
    C++ Primer
       Price: $4.99
    Emperor's New Mind
    Roger Penrose
       Price: $15.9
    Evening News
    Arthur Hailey
       Price: $9.99

The Command-line Pipeline Tool orapipe

The command-line pipeline tool is named orapipe. Before running it for the first time, add xmlparserv2.jar to your CLASSPATH. orapipe must have at least one argument, the pipeline document (pipedoc.xml in the code example presented in the preceding section).

To run orapipe:

orapipe options pipedoc

where pipedoc is the required pipeline document you prepare in advance.

Table 9-1 describes the available options:

Table 9-1 orapipe: Command-line Options

Option Purpose
-help Prints the help message
-log logfile Writes errors and messages to the log file you name. The default is pipeline.log.
-noinfo Do not log informational items. The default is on.
-nowarning Do not log any warnings. The default is on.
-validate Validate the input pipedoc with the pipeline schema. The default is do not validate.
-version Prints the release version.
-sequential Executes the pipeline in sequential mode. The default is parallel.