Example: Condensing an existing XPCML document, including Java code

The following example illustrates how to condense an existing XPCML document. The example includes original XPCML source, the resulting condensed XPCML, the Java™ code that calls condenseXPCML(), and a few of the newly generated type definitions in the extended schema:

Original XPCML source

     <!-- Fully specified XPCML source -->
     <xpcml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:noNamespaceSchemaLocation="xpcml.xsd" version="4.0">

     <struct name="qualifiedJobName">
        <stringParm name="jobName" length="10">*</stringParm>
        <stringParm name="userName" length="10"/>
        <stringParm name="jobNumber" length="6"/>
     </struct>

     <struct name="jobi0100">
        <intParm name="numberOfBytesReturned"/>
        <intParm name="numberOfBytesAvailable"/>
        <structParm name="qualifiedJobName" struct="qualifiedJobName"/>
        <hexBinaryParm name="internalJobIdentifier" totalBytes="16"/>
        <stringParm name="jobStatus" length="10"/>  
        <stringParm name="jobType" length="1"/>  
        <stringParm name="jobSubtype" length="1"/>  
        <stringParm length="2"/>  
        <intParm name="runPriority"/>
        <intParm name="timeSlice"/>
        <intParm name="defaultWait"/>
        <stringParm name="purge" length="10"/>  
     </struct>        

     <program name="qusrjobi_jobi0100" path="/QSYS.LIB/QUSRJOBI.PGM"> 
        <parameterList>        
           <structParm name="receiverVariable" passDirection="out"
              outputSize="lengthOfReceiverVariable" struct="jobi0100"/>
           <intParm name="lengthOfReceiverVariable" passDirection="in">86</intParm>
           <stringParm name="formatName" passDirection="in" length="8">JOBI0100</stringParm>
           <structParm name="qualifiedJobName" passDirection="in" struct="qualifiedJobName"/>
           <hexBinaryParm name="internalJobIdentifier"
              passDirection="in" totalBytes="16"> </hexBinaryParm>
           <intParm name="errorCode" passDirection="in">0</intParm>
        </parameterList> 
     </program>
     </xpcml>

Java code to condense the original XPCML source

     try {
        FileInputStream fullStream = new FileInputStream("myXPCML.xpcml");
        FileOutputStream condensedStream = new FileOutputStream("myCondensedXPCML.xpcml");
        FileOutputStream xsdStream = new FileOutputStream("myXSD.xsd");
        ProgramCallDocument.condenseXPCML(fullStream, xsdStream, condensedStream, "myXSD.xsd");

     }
     catch (Exception e) {
       System.out.println("error:  - "+e.getMessage());
       e.printStackTrace();
     }

Condensed XPCML source: myCondensedXPCML.xpcml

     <xpcml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xsi:noNamespaceSchemaLocation="myXSD.xsd" version="4.0">

     <struct name="qualifiedJobName">
        <jobName_>*</jobName_>
        <userName_/>
        <jobNumber_/>
     </struct>

     <struct name="jobi0100">
        <numberOfBytesReturned_/>
        <numberOfBytesAvailable_/>
        <structParm name="qualifiedJobName" struct="qualifiedJobName"/>
        <internalJobIdentifier_/>  
        <jobStatus_/>  
        <jobType_/>  
        <jobSubtype_/>  
        <stringParm length="2"/>  
        <runPriority_/>
        <timeSlice_/>
        <defaultWait_/>
        <purge_/>  
     </struct>        

     <program name="qusrjobi_jobi0100" path="/QSYS.LIB/QUSRJOBI.PGM"> 
        <parameterList>        
           <structParm name="receiverVariable" passDirection="out"
              outputSize="lengthOfReceiverVariable" struct="jobi0100"/>
           <lengthOfReceiverVariable_>86</lengthOfReceiverVariable_>
           <formatName_>JOBI0100</formatName_>
           <structParm name="qualifiedJobName" passDirection="in" struct="qualifiedJobName"/>
           <internalJobIdentifier_> </internalJobIdentifier_> 
           <errorCode_>0</errorCode_>                    
        </parameterList> 
     </program>
     </xpcml>

Some type definitions from the generated schema: myXSD.xsd

     <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
     <xs:include schemaLocation='xpcml.xsd'/>

     <xs:element name="jobName_" substitutionGroup="stringParmGroup" >
        <xs:complexType>
           <xs:simpleContent>
           <xs:restriction base="stringParmType">
              <xs:attribute name="name" type="string50" fixed="jobName" />
              <xs:attribute name="length" type="xs:string" fixed="10" />
           </xs:restriction>
           </xs:simpleContent>
        </xs:complexType>
     </xs:element>

     <xs:element name="userName_" substitutionGroup="stringParmGroup" >
        <xs:complexType>
           <xs:simpleContent>
           <xs:restriction base="stringParmType">
              <xs:attribute name="name" type="string50" fixed="userName" />
              <xs:attribute name="length" type="xs:string" fixed="10" />
           </xs:restriction>
           </xs:simpleContent>
        </xs:complexType>
     </xs:element>

     <xs:element name="jobNumber_" substitutionGroup="stringParmGroup" >
        <xs:complexType>
           <xs:simpleContent>
           <xs:restriction base="stringParmType">
              <xs:attribute name="name" type="string50" fixed="jobNumber" />
              <xs:attribute name="length" type="xs:string" fixed="6" />
           </xs:restriction>
           </xs:simpleContent>
        </xs:complexType>
     </xs:element>

     <xs:element name="lengthOfReceiverVariable_" substitutionGroup="intParmGroup" >
        <xs:complexType>
           <xs:simpleContent>
           <xs:restriction base="intParmType">
              <xs:attribute name="name" type="string50" fixed="lengthOfReceiverVariable" />
              <xs:attribute name="passDirection" type="passDirectionType" fixed="in" />
           </xs:restriction>
           </xs:simpleContent>
        </xs:complexType>
     </xs:element>

     <xs:element name="formatName_" substitutionGroup="stringParmGroup" >
        <xs:complexType>
           <xs:simpleContent>
           <xs:restriction base="stringParmType">
              <xs:attribute name="name" type="string50" fixed="formatName" />
              <xs:attribute name="length" type="xs:string" fixed="8" />
              <xs:attribute name="passDirection" type="passDirectionType" fixed="in" />
           </xs:restriction>
           </xs:simpleContent>
        </xs:complexType>
     </xs:element>

     <!-- More type definitions for each newly defined type follow here -->
     </xs:schema>