Generating a list of document versions

Iterating through multiple versions of multiple documents retrieved from one docbase.

To write a program that displays a list of all the version numbers for one or more documents:

  1. Write a query to retrieve a list of one or more documents.
    For the SampleNewsDocbase, you can use sample query AllNonSystemDocumentsQuery.xml to return a list of all documents in the docbase.
  2. Run the query, and store the list in an array:
    
    IxiaDocumentServices.Result [] documents = docServices.GetDocuments
                                   (subList,
                                    TextmlConstants.TEXTML_DOCUMENT_VERSIONS_LIST);
    
  3. For each document in the list, get and display: the name of the document; the version number of the document's current version; and a list of the previous version numbers (if any):
    
    // Process each document.
    // Either:
    // * Success: print the version info.
    // * Failure: print the error message.
    for (int i = 0; i < documents.Length; ++i)
    {
        if (documents[i].Error != null)
            {
                Console.WriteLine(documents[i].Error);
            }
    else
    // Display the name and version number of this document, followed by the
    // version number of each previous version that is still stored in the docbase.
    {
        Console.Write
           (String.Format("\nDocument: {0}" +
                          "\n  Current version number: {1}" +
                          "\n  Number of previous versions retained: {2}",
                          documents[i].Document.Name,
                          documents[i].Document.Version,
                          documents[i].Document.PreviousVersionList.Count));
    
        // If there are any previous versions of the document, display their
        // version numbers as a list.
        if (documents[i].Document.PreviousVersionList.Count > 0)
        {
            Console.WriteLine("\n  Version numbers (of the previous versions):");
    
            for (int j = 0;
                 j < documents[i].Document.PreviousVersionList.Count; ++j)
            {
                Console.Write
                    (String.Format("  {0} ",
                     documents[i].Document.PreviousVersionList[j]));
            }
        }
        Console.WriteLine("");
    
    }  // End of else block
    }  // End of for loop