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:
-
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. -
Run the query, and store the list in an array:
IxiaDocumentServices.Result [] documents = docServices.GetDocuments (subList, Constants.TEXTML_DOCUMENT_VERSIONS_LIST);
-
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: display the version info. // * Failure: display an error message. for (int i = 0; i < documents.length; ++i) { if (documents[i].error != null) { System.out.println(documents[i].error); } else { System.out.format ("Document: %s" + "\n Current version number: %d." + "\n Number of previous versions retained: %d", documents[i].document.GetName(), documents[i].document.GetVersion(), documents[i].document.GetPreviousVersionList().length); // If there are any previous versions of the document, display their // version numbers as a list. if (documents[i].document.GetPreviousVersionList().length > 0) { System.out.println ("\n Version numbers (of the previous versions):"); for (int j=0; j<documents[i].document.GetPreviousVersionList().length; ++j) { System.out.format (" %d ", documents[i].document.GetPreviousVersionList()[j]); } } System.out.println(""); System.out.println(""); } // End of else block } // End of for loop