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.

134 lines
5.2 KiB

  1. Attribute VB_Name = "SubSite"
  2. Option Explicit
  3. Private Const HHT_ELEMENT_TAXONOMY_ENTRY_C As String = "/METADATA/TAXONOMY_ENTRIES/TAXONOMY_ENTRY"
  4. Private Const HHT_ATTR_CATEGORY_C As String = "CATEGORY"
  5. Private Const HHT_ATTR_ENTRY_C As String = "ENTRY"
  6. Private Const HHT_ATTR_URI_C As String = "URI"
  7. Private Const HHT_ATTR_SUBSITE_C As String = "SUBSITE"
  8. Private Const HHT_ATTR_TITLE_C As String = "TITLE"
  9. Private Const SUBSITES_ELEMENT_NODE_C As String = "SUBSITES/NODE"
  10. Private Const SUBSITES_ELEMENT_TOPIC_C As String = "SUBSITES/TOPIC"
  11. Private Const SUBSITES_ATTR_CATEGORY_C As String = "CATEGORY"
  12. Private Const SUBSITES_ATTR_ENTRY_C As String = "ENTRY"
  13. Private Const SUBSITES_ATTR_URI_C As String = "URI"
  14. Public Sub MarkSubSites( _
  15. ByVal i_strFolder As String, _
  16. ByVal i_strSubSiteXML As String _
  17. )
  18. Dim DOMDocPkgDesc As MSXML2.DOMDocument
  19. Dim DOMDocSubSiteXML As MSXML2.DOMDocument
  20. Dim intNumHHTs As Long
  21. Dim intIndex As Long
  22. Dim arrDOMDoc() As MSXML2.DOMDocument
  23. Dim arrFileName() As String
  24. Dim strFile As String
  25. frmMain.Output "Marking SubSites...", LOGGING_TYPE_NORMAL_E
  26. Set DOMDocPkgDesc = GetPackageDescription(i_strFolder)
  27. intNumHHTs = GetNumberOfHHTsListedInPackageDescription(DOMDocPkgDesc)
  28. Set DOMDocSubSiteXML = GetFileAsDomDocument(i_strSubSiteXML)
  29. ReDim arrDOMDoc(intNumHHTs - 1)
  30. ReDim arrFileName(intNumHHTs - 1)
  31. For intIndex = 1 To intNumHHTs
  32. strFile = i_strFolder & "\" & GetNthHHTListedInPackageDescription(DOMDocPkgDesc, intIndex)
  33. Set arrDOMDoc(intIndex - 1) = GetFileAsDomDocument(strFile)
  34. arrFileName(intIndex - 1) = strFile
  35. Next
  36. p_MarkSubSites2 DOMDocSubSiteXML, arrDOMDoc, arrFileName
  37. End Sub
  38. Private Sub p_MarkSubSites2( _
  39. ByVal i_DOMDocSubSiteXML As MSXML2.DOMDocument, _
  40. ByRef u_arrDOMDoc() As MSXML2.DOMDocument, _
  41. ByRef i_arrFileName() As String _
  42. )
  43. Dim DOMNodeList As MSXML2.IXMLDOMNodeList
  44. Dim DOMNode As MSXML2.IXMLDOMNode
  45. Dim DOMElement As MSXML2.IXMLDOMElement
  46. Dim strCategory As String
  47. Dim strEntry As String
  48. Dim strURI As String
  49. Dim intIndex As Long
  50. Dim strQueryString As String
  51. Dim blnFound As Boolean
  52. Set DOMNodeList = i_DOMDocSubSiteXML.selectNodes(SUBSITES_ELEMENT_NODE_C)
  53. For Each DOMNode In DOMNodeList
  54. strCategory = p_GetAttribute(DOMNode, SUBSITES_ATTR_CATEGORY_C)
  55. strEntry = p_GetAttribute(DOMNode, SUBSITES_ATTR_ENTRY_C)
  56. blnFound = False
  57. For intIndex = LBound(u_arrDOMDoc) To UBound(u_arrDOMDoc)
  58. strQueryString = HHT_ELEMENT_TAXONOMY_ENTRY_C & "["
  59. strQueryString = strQueryString & "@" & HHT_ATTR_CATEGORY_C & "=""" & strCategory & """ and "
  60. strQueryString = strQueryString & "@" & HHT_ATTR_ENTRY_C & "=""" & strEntry & """]"
  61. Set DOMElement = u_arrDOMDoc(intIndex).selectSingleNode(strQueryString)
  62. If (Not DOMElement Is Nothing) Then
  63. DOMElement.setAttribute HHT_ATTR_SUBSITE_C, "TRUE"
  64. blnFound = True
  65. Exit For
  66. End If
  67. Next
  68. If (Not blnFound) Then
  69. frmMain.Output "Not found: Category: " & strCategory & ", Entry: " & strEntry, LOGGING_TYPE_WARNING_E
  70. End If
  71. Next
  72. Set DOMNodeList = i_DOMDocSubSiteXML.selectNodes(SUBSITES_ELEMENT_TOPIC_C)
  73. For Each DOMNode In DOMNodeList
  74. strCategory = p_GetAttribute(DOMNode, SUBSITES_ATTR_CATEGORY_C)
  75. strURI = p_GetAttribute(DOMNode, SUBSITES_ATTR_URI_C)
  76. strEntry = p_GetAttribute(DOMNode, SUBSITES_ATTR_ENTRY_C)
  77. blnFound = False
  78. For intIndex = LBound(u_arrDOMDoc) To UBound(u_arrDOMDoc)
  79. strQueryString = HHT_ELEMENT_TAXONOMY_ENTRY_C & "["
  80. strQueryString = strQueryString & "@" & HHT_ATTR_CATEGORY_C & "=""" & strCategory & """ and "
  81. strQueryString = strQueryString & "@" & HHT_ATTR_URI_C & "=""" & strURI & """]"
  82. Set DOMElement = u_arrDOMDoc(intIndex).selectSingleNode(strQueryString)
  83. If (Not DOMElement Is Nothing) Then
  84. DOMElement.setAttribute HHT_ATTR_SUBSITE_C, "TRUE"
  85. DOMElement.setAttribute HHT_ATTR_ENTRY_C, Mangle(strEntry)
  86. blnFound = True
  87. Exit For
  88. End If
  89. Next
  90. If (Not blnFound) Then
  91. frmMain.Output "Not found: Category: " & strCategory & ", URI: " & strURI, LOGGING_TYPE_WARNING_E
  92. End If
  93. Next
  94. For intIndex = LBound(u_arrDOMDoc) To UBound(u_arrDOMDoc)
  95. u_arrDOMDoc(intIndex).save i_arrFileName(intIndex)
  96. Next
  97. End Sub
  98. Private Function p_GetAttribute( _
  99. ByVal i_DOMNode As MSXML2.IXMLDOMNode, _
  100. ByVal i_strAttributeName As String _
  101. ) As String
  102. Dim DOMAttribute As MSXML2.IXMLDOMAttribute
  103. Set DOMAttribute = i_DOMNode.Attributes.getNamedItem(i_strAttributeName)
  104. If (DOMAttribute Is Nothing) Then
  105. Err.Raise E_FAIL, , "Attribute " & i_strAttributeName & " is missing in: " & i_DOMNode.XML
  106. End If
  107. p_GetAttribute = Replace$(DOMAttribute.Text, "\", "\\")
  108. End Function