Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
4.7 KiB

  1. Attribute VB_Name = "HHTs"
  2. Option Explicit
  3. Private Const HHT_TAXONOMY_C As String = "METADATA/TAXONOMY_ENTRIES/TAXONOMY_ENTRY"
  4. Private Const HHT_STOPSIGN_C As String = "METADATA/STOPSIGN_ENTRIES/STOPSIGN"
  5. Private Const HHT_STOPWORD_C As String = "METADATA/STOPWORD_ENTRIES/STOPWORD"
  6. Private Const HHT_SYNSET_C As String = "METADATA/SYNTABLE/SYNSET"
  7. Private Const HHT_OPERATOR_C As String = "METADATA/OPERATOR_ENTRIES/OPERATOR"
  8. Private Const HHT_FTS_C As String = "METADATA/FTS"
  9. Private Const HHT_SCOPE_DEFINITION_C As String = "METADATA/SCOPE_DEFINITION"
  10. Private Const HHT_INDEX_C As String = "METADATA/INDEX"
  11. Private Const HHT_HELPIMAGE_C As String = "METADATA/HELPIMAGE"
  12. Private Const HHT_EXTENSION_C As String = ".HHT"
  13. Public Sub ImportHHTs2MDB( _
  14. ByVal i_strFolder As String, _
  15. ByVal i_strDatabase As String, _
  16. ByVal i_intSKU As Long, _
  17. ByVal i_blnIgnoreTaxonomy As Boolean _
  18. )
  19. On Error GoTo LError
  20. OpenDatabaseAndSetSKU i_strDatabase, i_intSKU
  21. p_ProcessFolder i_strFolder, i_blnIgnoreTaxonomy
  22. FinalizeDatabase
  23. LEnd:
  24. Exit Sub
  25. LError:
  26. frmMain.Output Err.Description, LOGGING_TYPE_ERROR_E
  27. Err.Raise Err.Number
  28. End Sub
  29. Private Sub p_ProcessFolder( _
  30. ByVal i_strFolder As String, _
  31. ByVal i_blnIgnoreTaxonomy As Boolean _
  32. )
  33. On Error GoTo LError
  34. Dim FSO As Scripting.FileSystemObject
  35. Dim Folder As Scripting.Folder
  36. Dim File As Scripting.File
  37. Dim DOMNodeHHT As MSXML2.DOMDocument
  38. Set FSO = New Scripting.FileSystemObject
  39. Set Folder = FSO.GetFolder(i_strFolder)
  40. For Each File In Folder.Files
  41. If (InStr(1, File.Name, HHT_EXTENSION_C, vbTextCompare) <> 0) Then
  42. Set DOMNodeHHT = p_LoadHht(File.Path)
  43. frmMain.Output "Importing file " & File.Name, LOGGING_TYPE_NORMAL_E
  44. p_ImportHHT DOMNodeHHT, i_blnIgnoreTaxonomy
  45. End If
  46. Next
  47. LEnd:
  48. Exit Sub
  49. LError:
  50. Err.Raise E_FAIL, , Err.Description
  51. End Sub
  52. Private Function p_LoadHht( _
  53. ByVal i_strHhtFile As String _
  54. ) As MSXML2.IXMLDOMNode
  55. On Error GoTo LError
  56. Dim DOMDocHHT As MSXML2.DOMDocument
  57. Set DOMDocHHT = New MSXML2.DOMDocument
  58. DOMDocHHT.async = False
  59. DOMDocHHT.Load i_strHhtFile
  60. If (DOMDocHHT.parseError <> 0) Then
  61. p_DisplayParseError DOMDocHHT.parseError
  62. GoTo LError
  63. End If
  64. Set p_LoadHht = DOMDocHHT
  65. LEnd:
  66. Exit Function
  67. LError:
  68. Err.Raise E_FAIL, , "Unable to read HHT file " & i_strHhtFile & ": " & Err.Description
  69. End Function
  70. Private Sub p_ImportHHT( _
  71. ByVal i_DOMNodeHHT As MSXML2.IXMLDOMNode, _
  72. ByVal i_blnIgnoreTaxonomy As Boolean _
  73. )
  74. On Error GoTo LError
  75. Dim DOMNodeList As MSXML2.IXMLDOMNodeList
  76. Dim DOMNode As MSXML2.IXMLDOMNode
  77. Dim strXML As String
  78. Dim arrNode() As String
  79. Dim intIndex As Long
  80. If (Not i_blnIgnoreTaxonomy) Then
  81. Set DOMNodeList = i_DOMNodeHHT.selectNodes(HHT_TAXONOMY_C)
  82. For Each DOMNode In DOMNodeList
  83. DoEvents
  84. ImportTaxonomyEntry DOMNode
  85. Next
  86. End If
  87. Set DOMNodeList = i_DOMNodeHHT.selectNodes(HHT_OPERATOR_C)
  88. ImportOperators DOMNodeList
  89. Set DOMNodeList = i_DOMNodeHHT.selectNodes(HHT_STOPSIGN_C)
  90. For Each DOMNode In DOMNodeList
  91. DoEvents
  92. ImportStopSign DOMNode
  93. Next
  94. Set DOMNodeList = i_DOMNodeHHT.selectNodes(HHT_STOPWORD_C)
  95. For Each DOMNode In DOMNodeList
  96. DoEvents
  97. ImportStopWord DOMNode
  98. Next
  99. Set DOMNodeList = i_DOMNodeHHT.selectNodes(HHT_SYNSET_C)
  100. For Each DOMNode In DOMNodeList
  101. DoEvents
  102. ImportSynset DOMNode
  103. Next
  104. ReDim arrNode(3)
  105. arrNode(0) = HHT_FTS_C
  106. arrNode(1) = HHT_SCOPE_DEFINITION_C
  107. arrNode(2) = HHT_INDEX_C
  108. arrNode(3) = HHT_HELPIMAGE_C
  109. For intIndex = LBound(arrNode) To UBound(arrNode)
  110. Set DOMNode = i_DOMNodeHHT.selectSingleNode(arrNode(intIndex))
  111. If (Not DOMNode Is Nothing) Then
  112. strXML = strXML & vbCrLf & DOMNode.XML
  113. End If
  114. Next
  115. SetDomFragment strXML
  116. LEnd:
  117. Exit Sub
  118. LError:
  119. Err.Raise E_FAIL, , "ImportHHT failed: " & Err.Description
  120. End Sub
  121. Private Sub p_DisplayParseError( _
  122. ByRef i_ParseError As MSXML2.IXMLDOMParseError _
  123. )
  124. Dim strError As String
  125. With i_ParseError
  126. strError = "Error: " & .reason & _
  127. "Line: " & .Line & vbCrLf & _
  128. "Linepos: " & .linepos & vbCrLf & _
  129. "srcText: " & .srcText
  130. End With
  131. frmMain.Output strError, LOGGING_TYPE_ERROR_E
  132. End Sub