After initialization the API calls the
SmartXMLTypeCount method of the ISmartDocument interface within
CustomerDocument.vb. In this case, because you have three types the return value should be
3. The
types Hashtable contains the list of these types so a simple Count function returns the number of items stored in the collection.
Public Shared Function Count() As Integer
Return types.Count
End Function
Next, the API calls the
SmartDocXmlTypeName and
SmartDocXmlTypeCaption for each type. In these methods you make calls to
DocumentUtils.Name and
DocumentUtils.Caption.
In each of these cases the XMLTypeID used will be iterative. The order of the calls follows the sequence shown in Table 3.
Table 3. Method Call Sequence. The Office API calls these methods in sequence for the three XmlTypes defined in the sample application.
| Method
|
XMLTypeID
|
Value
|
| SmartDocXmlTypeName
|
1
|
http://Officesamples/Customer/2004#documentRoot
|
| SmartDocXmlTypeCaption
|
1
|
Root content
|
| SmartDocXmlTypeName
|
2
|
http://Officesamples/Customer/2004#region
|
| SmartDocXmlTypeCaption
|
2
|
Region selection
|
| SmartDocXmlTypeName
|
3
|
http://Officesamples/Customer/2004#itemname
|
| SmartDocXmlTypeCaption
|
3
|
Item Selection
|
Remember that the SmartType stores the return values for Caption and Name while initializing each XmlType instance.
Public Shared Function Name( _
ByVal XMLTypeId As Integer) As String
Dim XMLTypeName As String = GetTypeName(XMLTypeId)
If types.ContainsKey(XMLTypeName) Then
Return XMLTypeName
End If
End Function
The preceding snippet uses the
GetTypeName(XMLTypeId) call to fetch the XMLTypeName for the XMLTypeID. The XMLTypeName is the key for the
types hashtable, from which you retrieve the appropriate SmartNode and its corresponding Caption/Name.