# PackageDoc (PKGD)

The PackageDoc schemas are designed to control the process of document assembly. Each Expere IE document will have at least one PKGD document. The PackageDoc object is returned as part of the DocSet object (as the PackageDocs parameter with an ArrayOfPackageDoc type).

The PackageDoc contains two main collections of information about a document: DocDescriptor and DocWorkOrder.

     <xs:complexType name="PackageDoc">
     <xs:sequence>
     <xs:element minOccurs="0" maxOccurs="1" name="DocDescriptor" type="tns:DocDescriptor"/>
     <xs:element minOccurs="0" maxOccurs="1" name="DocWorkOrder" type="tns:DocWorkOrder"/>
     </xs:sequence>
     <xs:attribute name="PackageDocID" type="xs:string"/>
     </xs:complexType>

The DocDescriptor contains information about the document that must be available in order to locate and assemble the document. A visual representation of the DocDescriptor object looks like:
Here is an example of a DocDescriptor element.

    <DocDescriptor>
    <DocID>PKGD.FannieMaeFreddieMac3200_FixedRateeNoteMultistate_VMP5E.RTF1</DocID>
    <DocType>Dynamic</DocType>
    <DocDisplayName>Fannie Mae/Freddie Mac 3200 Fixed Rate eNote (Multistate) VMP5E
    </DocDisplayName>
    <DocRootEntityName>INS.FannieMaeFreddieMac3200_FixedRateeNoteMultistate_VMP5E
    </DocRootEntityName>
    <DocCustomDataItems>
    <!-- DocCustomDataItem will be here -->
    </DocCustomDataItems>
    <DocumentClass>Note</DocumentClass>
    <DocumentTypeDescription/>
    <NegotiableInstrumentFlag>true</NegotiableInstrumentFlag>
    <RecordableFlag>false</RecordableFlag>
    <FormNumber>3200e</FormNumber>
    </DocDescriptor>

A DocWorkOrder contains instructions for selecting and preparing a document. It is structured so that business rules can be applied to produce the values of its elements. Business rules may be customized that differentiate when a RTF Doc PackageDoc or a corresponding PDF PackageDoc gets returned. If the DocumentFormat parameter is NOT supplied, the DocFormat value specified in the PackageDoc will be honored. This results in the ability to produce mixed document output formats with a single assemble document request. A visual representation of the DocDescriptor object looks like:
Here is an example of a DocWorkOrder element.

    <DocWorkOrder>
    <erl:choose>
    <erl:when test="selector.Select(T_Select_D5E())">
    <DocPrepare>true</DocPrepare>
    <DocAutoselected>true</DocAutoselected>
    <DocSuggested>true</DocSuggested>
    </erl:when>
    <erl:otherwise>
    <DocPrepare>false</DocPrepare>
    <DocAutoselected>false</DocAutoselected>
    <DocSuggested>
    <erl:write exp="selector.Suggest(T_Select_D5E()).ToString()"/>
    </DocSuggested>
    </erl:otherwise>
    </erl:choose>
    <DocFormat>RTF/1</DocFormat>
    <DocStyle/>
    </DocWorkOrder>