Creating a Topic Map

Top  Previous  Next

To create a topic map, first create a TopicMapServiceClient instance, then use the CreateTopicMap() method on that instance to create the new topic map. When creating the topic map it is necessary to pass in the base address of the Web3 server and the web address of the schema. After the topic map is created it is necessary to synchronize the topic map with its schema. The synchronization process ensures that all types in the schema have a matching topic in the topic map and creates a map-specific version of the schema that can be quickly accessed by schema-driven applications. This synchronization is performed by calling the SynchronizeSchemas() method on the TopicMap instance returned by CreateTopicMap(). Whenever the schema that a topic map uses is updated, the SynchronizeSchemas() method should be called to resynchronize the topic map with its schema.

 

      /// <summary>

      /// Creates a new topic map and returns its web address

      /// </summary>

      /// <param name="schemaUri">The web address of the schema that the topic map should be synchronized with</param>

      /// <returns>The web address of the newly created topic map</returns>

      private Uri CreateTopicMap(Uri schemaUri)

       {

          // create a topic map service client

          var client = new TopicMapServiceClient();

 

          // create topic map

          // this operation does create a topic map on the server.

          var tm = client.CreateTopicMap(_baseUri, schemaUri, new Label("myTopicMap", "en"));

 

          // The SynchronizeSchemas() call is necessary to ensure that all topic types

          // from the schema are created in the topicmap and the topic map schema is cached

          Console.WriteLine("Schema synchronization started");

           tm.SynchronizeSchemas();

          Console.WriteLine("Schema synchronization completed");

          return tm.WebAddress;

       }