Advertisement
Advertisement
| 06.06.2008 at 08:33AM PDT, ID: 23464091 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: |
Public Function ValidateXML(ByVal sXMLPath As String, ByVal sXSDPath As String) As String
Dim sNamespace As String
Dim objSchemas As Object
Dim oXML As Object
Dim oXSD As Object
Dim oErr As Object
On Error Resume Next
ValidateXML = ""
'Load XSD as DOM to populate in Schema Cache
Set oXSD = CreateObject("MSXML2.DOMDocument.4.0")
If Err.number <> 0 Then
ValidateXML = "Fail - ActiveX Component Load failure"
Exit Function
End If
oXSD.async = False
If Not oXSD.Load(sXSDPath) Then
ValidateXML = "Fail - XSD Load failure"
Exit Function
Else
'Get namespace name from XSD TargetNamespace attribute
sNamespace = oXSD.documentElement.getAttribute("targetNamespace")
End If
'Populate schema cache
Set objSchemas = CreateObject("MSXML2.XMLSchemaCache.4.0")
If Err.number <> 0 Then
ValidateXML = "Fail - ActiveX Component Load failure"
Exit Function
End If
objSchemas.Add sNamespace, oXSD
'Load XML file (without validation - that comes later)
Set oXML = CreateObject("MSXML2.DOMDocument.4.0")
If Err.number <> 0 Then
ValidateXML = "Fail - ActiveX Component Load failure"
Exit Function
End If
oXML.async = False
oXML.validateOnParse = False
oXML.resolveExternals = False
'Load XML, without any validation
If Not oXML.Load(sXMLPath) Then
ValidateXML = "Fail - XML Load failure"
Exit Function
End If
'Bind Schema Cache to DOM
Set oXML.schemas = objSchemas
'Does this XML measure up?
Set oErr = oXML.Validate()
If oErr.errorCode <> 0 Then
ValidateXML = "Fail - " & oErr.reason
Else
ValidateXML = ""
End If
End Function
|