Using collections to organize a docbase
How to create collections. How to store and retrieve documents in collections.
IxiaDocBaseServices docbase = // ...
Documents stored in document bases are kept in the repository, in which they can be grouped and organized hierarchically, in a tree-like structure, as they would be in a Windows or Linux file system.
Each node of the tree is called a collection. Collections are containers for documents and other collections.
The root collection is the repository itself: the repository can contain collections and documents that are not in collections.
In TEXTML Console (a management application delivered as part of TEXTML Server), collections are displayed graphically much like the directories (folders) in the Windows file system.
To create collections in a document base:
Get an IxiaCollectionServices object from the
IxiaCollectionServices provides access to the services for managing collections in the document base.
IxiaCollectionServices CollectionSrv = dss.CollectionServices();
Create each collection (an IxiaCollection object) with the
CreateCollection() method of the
// collectionName is a String object IxiaCollection Collection1 = CollectionSrv.CreateCollection(collectionName, CREATE_NEW_COLLECTION);Here are the options:
Newly created collections are empty.
- COLLECTION_CREATION_MODE_CREATE_NEW: Creates a new collection and returns it.
- COLLECTION_CREATION_MODE_CREATE_ALWAYS: Returns the collection if it exists; otherwise, creates a new collection and returns it.
- COLLECTION_CREATION_MODE_OPEN_EXISTING: Returns the collection if it exists; otherwise, throws a TextmlserverError exception.
Adding documents to a collection. When
setting a document's properties in preparation to adding the document to a
docbase, specify the name of the collection. If the collection is contained in a
higher-level collection, specify the collection name as a path:
document.SetName("review1001.xml"); document.SetCollection("/news/entertainment/film");When the document is added to the docbase (by a call to IxiaDocumentServices.setDocuments()), it will automatically be added to the specified collection.Note: To separate collection names in a path, always use "/", the forward slash key.
Retrieving a document by its name and
collection. Specify the document's collection path in the same string as its
String  documents = new String; String documentName = "/news/entertainment/film/review1001.xml"; documents = documentName; IxiaDocumentServices.Result  result = ds.GetDocuments(documents, // <ds> is an IxiaDocumentServices object Constants.TEXTML_DOCUMENT_CONTENT | Constants.TEXTML_DOCUMENT_PROPERTIES, Constants.TEXTML_DOCUMENT);
You can easily modify sample program SetDocuments to add documents to a specified collection in the specified docbase:
To use sample program GetDocument to get a document that is in a collection, you do not need to change the program. When you run GetDocument, specify the collection path as part of the document name:
getdocument user=domain\user password=yourpass docbase=test server=localhost « path=c:\Temp\ docname=news/entertainment/film/review1001.xml
Do not confuse the directory path of document files on disk with the collection path of documents in a docbase. In the above command:
- docname=news/entertainment/film/review1001.xml is the collection path and document name of a document in docbase test .
- path=c:\Temp\ is the location on disk where the document will be saved. (The separator is a backslash ("/") because the file system, in this example, is Windows. For Linux, use a forward slash ("/") as you would normally.)