当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET XmlSchemaInclude类代码示例

本文整理汇总了VB.NET中System.Xml.Schema.XmlSchemaInclude的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlSchemaInclude类的具体用法?VB.NET XmlSchemaInclude怎么用?VB.NET XmlSchemaInclude使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XmlSchemaInclude类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: ImportIncludeSample

' 导入命名空间
Imports System.Collections
Imports System.IO
Imports System.Xml
Imports System.Xml.Xsl
Imports System.Xml.Schema


Public Class ImportIncludeSample

    Private Shared Sub ValidationCallBack(ByVal sender As Object, ByVal args As ValidationEventArgs)

        If args.Severity = XmlSeverityType.Warning Then
            Console.Write("WARNING: ")
        Else
            If args.Severity = XmlSeverityType.Error Then
                Console.Write("ERROR: ")
            End If
        End If
        Console.WriteLine(args.Message)
    End Sub


    Public Shared Sub Main()

        Dim schema As New XmlSchema()
        schema.ElementFormDefault = XmlSchemaForm.Qualified
        schema.TargetNamespace = "http://www.w3.org/2001/05/XMLInfoset"

        ' <xs:import namespace="http://www.example.com/IPO" />             
        Dim import As New XmlSchemaImport()
        import.Namespace = "http://www.example.com/IPO"
        schema.Includes.Add(import)

        ' <xs:include schemaLocation="example.xsd" />     
        Dim include As New XmlSchemaInclude()
        include.SchemaLocation = "example.xsd"
        schema.Includes.Add(include)

        Dim schemaSet As New XmlSchemaSet()
        AddHandler schemaSet.ValidationEventHandler, AddressOf ValidationCallBack

        schemaSet.Add(schema)
        schemaSet.Compile()

        Dim compiledSchema As XmlSchema = Nothing

        For Each schema1 As XmlSchema In schemaSet.Schemas()
            compiledSchema = schema1
        Next

        Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(New NameTable())
        nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema")
        compiledSchema.Write(Console.Out, nsmgr)

    End Sub
End Class

'ImportIncludeSample
开发者ID:VB.NET开发者,项目名称:System.Xml.Schema,代码行数:59,代码来源:XmlSchemaInclude


注:本文中的System.Xml.Schema.XmlSchemaInclude类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。