Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 3 - Generating XML Schema Dynamically Using VB...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Generating XML Schema Dynamically Using VB.NET 2005: Annotations and Nesting Complex Types
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2006-02-13

    Table of Contents:
  • Generating XML Schema Dynamically Using VB.NET 2005: Annotations and Nesting Complex Types
  • Understanding the dynamic generation of complex type in XML Schema
  • Generate XML Schema annotations dynamically using the .NET framework
  • Understanding the generation of XML Schema annotations dynamically using the .NET framework

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Generating XML Schema Dynamically Using VB.NET 2005: Annotations and Nesting Complex Types - Generate XML Schema annotations dynamically using the .NET framework


    (Page 3 of 4 )

    Every element in an XML schema can be provided with some documentation and annotation.  We can even have them dynamically created.  Let us first consider the following XML Schema:

    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="Organization">
        <xs:annotation>
          <xs:documentation>Employees list in the Pacific Northwest of US</xs:documentation>
        </xs:annotation>
        <xs:complexType />
      </xs:element>
    </xs:schema>

    The above schema mainly contains a root element, “Organization.”  You can also observe that “Organization” is currently a complex type.  It is provided with some annotation with documentation.  To generate the above XML Schema dynamically, we can consider the following complete code listing:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Me.TextBox1.Text = ""
            Dim schema As New XmlSchema()
     
            Dim eOrganization As New XmlSchemaElement
            schema.Items.Add(eOrganization)
            eOrganization.Name = "Organization"
     
            Dim aOrganization As New XmlSchemaAnnotation
            eOrganization.Annotation = aOrganization
            Dim dOrganization As New XmlSchemaDocumentation
            aOrganization.Items.Add(dOrganization)
            dOrganization.Markup = TextToNodeArray("Employees list in the Pacific Northwest of US")
     
            Dim ctOrganization As New XmlSchemaComplexType
            eOrganization.SchemaType = ctOrganization
       
            Dim nsmgr As New XmlNamespaceManager(New NameTable())
            nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema")
            Dim sw As New IO.StringWriter
            schema.Write(sw, nsmgr)
            Me.TextBox1.Text = sw.ToString
        End Sub
     
      Public Shared Function TextToNodeArray(ByVal text As String) As XmlNode()
            Dim doc As New XmlDocument()
            Return New XmlNode(0) {doc.CreateTextNode(text)}
        End Function


    You can find a step-by-step explanation of the above code in the next section.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hello guys. This is second part of my series on "Generating XML Schema dynamically...
     

    VISUAL BASIC.NET ARTICLES

    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway