Hi all,
As you know, the XMLValidatingRe ader is deprecated in .NET 2.0. I have the
following snippet from a .NET 1.1 implementation that I am struggling to
upgrade. I know I should use XMLReader.Creat e, but am struggling to get much
further. Any help would be appreciated. Thanks.
Public Shared Sub ValidateDocumen t(businessDocum ent As XmlDocument,
schemaStrongNam e As String)
' Constants
Const PARTS_IN_SCHEMA _STRONG_NAME As Integer = 2
Const PART_CLASS_NAME As Integer = 0
Const PART_QUALIFIED_ ASSEMBLY_NAME As Integer = 1
' Parse schema strong name
Dim assemblyNamePar ts As String() = schemaStrongNam e.Split(New Char()
{","c}, PARTS_IN_SCHEMA _STRONG_NAME)
Dim className As String = assemblyNamePar ts(PART_CLASS_N AME).Trim()
Dim fullyQualifiedA ssemblyName As String =
assemblyNamePar ts(PART_QUALIFI ED_ASSEMBLY_NAM E).Trim()
' Load assembly
Dim schemaAssembly As [Assembly] =
[Assembly].Load(fullyQual ifiedAssemblyNa me)
' Create instance of the BTS schema in order to get to the actual schemas
Dim schemaType As Type = schemaAssembly. GetType(classNa me)
Dim btsSchemaCollec tion As Microsoft.XLANG s.BaseTypes.Sch emaBase =
CType(Activator .CreateInstance (schemaType),
Microsoft.XLANG s.BaseTypes.Sch emaBase)
' Set up XML validating reader and validate document
Dim parserContext As New XmlParserContex t(Nothing, Nothing, "",
XmlSpace.None)
Dim reader As New XmlValidatingRe ader(businessDo cument.OuterXml ,
XmlNodeType.Doc ument, parserContext)
reader.Validati onType = ValidationType. Schema
reader.Schemas. Add(btsSchemaCo llection.Schema Collection)
While reader.Read()
End While
End Sub 'ValidateDocume nt
--
John
As you know, the XMLValidatingRe ader is deprecated in .NET 2.0. I have the
following snippet from a .NET 1.1 implementation that I am struggling to
upgrade. I know I should use XMLReader.Creat e, but am struggling to get much
further. Any help would be appreciated. Thanks.
Public Shared Sub ValidateDocumen t(businessDocum ent As XmlDocument,
schemaStrongNam e As String)
' Constants
Const PARTS_IN_SCHEMA _STRONG_NAME As Integer = 2
Const PART_CLASS_NAME As Integer = 0
Const PART_QUALIFIED_ ASSEMBLY_NAME As Integer = 1
' Parse schema strong name
Dim assemblyNamePar ts As String() = schemaStrongNam e.Split(New Char()
{","c}, PARTS_IN_SCHEMA _STRONG_NAME)
Dim className As String = assemblyNamePar ts(PART_CLASS_N AME).Trim()
Dim fullyQualifiedA ssemblyName As String =
assemblyNamePar ts(PART_QUALIFI ED_ASSEMBLY_NAM E).Trim()
' Load assembly
Dim schemaAssembly As [Assembly] =
[Assembly].Load(fullyQual ifiedAssemblyNa me)
' Create instance of the BTS schema in order to get to the actual schemas
Dim schemaType As Type = schemaAssembly. GetType(classNa me)
Dim btsSchemaCollec tion As Microsoft.XLANG s.BaseTypes.Sch emaBase =
CType(Activator .CreateInstance (schemaType),
Microsoft.XLANG s.BaseTypes.Sch emaBase)
' Set up XML validating reader and validate document
Dim parserContext As New XmlParserContex t(Nothing, Nothing, "",
XmlSpace.None)
Dim reader As New XmlValidatingRe ader(businessDo cument.OuterXml ,
XmlNodeType.Doc ument, parserContext)
reader.Validati onType = ValidationType. Schema
reader.Schemas. Add(btsSchemaCo llection.Schema Collection)
While reader.Read()
End While
End Sub 'ValidateDocume nt
--
John
Comment