Converting existing PCML to XPCML

The ProgramCallDocument class contains the transformPCMLToXPCML method that enables you to transform existing PCML documents to equivalent XPCML documents.

XPCML has comparable definitions for all of the elements and attributes that you can define in PCML. Using transformPCMLToXPCML() converts the PCML representation of the elements and attributes to the equivalent XPCML.

Note that in some cases, equivalent XPCML attributes have a different name than in PCML. For example, the attribute "usage" in PCML is the attribute "passDirection" in XPCML. For more information about how to use XPCML compared to PCML, see XPCML schema and syntax.

The method takes the existing PCML document, which you pass to it as an InputStream object, and generates the equivalent XPCML as an OutputStream object. Because transformPCMLToXPCML() is a static method, you can call it without first creating a ProgramCallDocument object.

Example: Converting a PCML document to an XPCML document

The following example shows how to convert a PCML document (named myPCML.pcml) to an XPCML document (named myXPCML.xpcml).

Note: You must specify .xpcml as the file extension for XPCML files. Using .xpcml as the file extension ensures that the ProgramCallDocument class recognizes the file as XPCML. If you do not specify an extension, ProgramCallDocument assumes that the file is PCML.

PCML document myPCML.pcml

     <!-- myPCML.pcml -->
     <pcml version="4.0">
        <program name="prog1" path="/QSYS.LIB/W95LIB.LIB/PROG1.PGM"> 
           <data type="char" name="parm1" usage="in" passby="reference"
                 minvrm="V5R2M0" ccsid="37" length="10" init="Value 1"/>
        </program>
     </pcml>

Java™ code to convert myPCML.pcml to myPCML.xpcml

     try {
       InputStream pcmlStream = new FileInputStream("myPCML.pcml");
       OutputStream xpcmlStream = new FileOutputStream("myXPCML.xpcml");
       ProgramCallDocument.transformPCMLToXPCML(pcmlStream, xpcmlStream);
     }
     catch (Exception e) {
       System.out.println("error:  - "+e.getMessage());
       e.printStackTrace();
     }

Resulting XPCML document myXPCML.xpcml

     <?xml version="1.0" encoding="UTF-8"?>
        <!-- myXPCML.xpcml -->
        <xpcml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xsi:noNamespaceSchemaLocation="xpcml.xsd" version="4.0">
        <program name="prog1" path="/QSYS.LIB/W95LIB.LIB/PROG1.PGM"> 
           <parameterList>
              <stringParm name="parm1" passDirection="in" passMode="reference" 
                          minvrm="V5R2M0" ccsid="37" length="10">Value 1
              </stringParm>
           </parameterList>
        </program>
     </xpcml>

For more information about transformPCMLToXPCML() and the ProgramCallDocument class, see the following page:

ProgramCallDocument javadoc information