SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 2 - 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: Working With Attributes
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2006-02-20

    Table of Contents:
  • Generating XML Schema Dynamically Using VB.NET 2005: Working With Attributes
  • Generate XML Schema attributes dynamically using .NET framework: source code
  • Generate XML Schema attributes dynamically using .NET framework: explanation
  • Generate more XML Schema attributes dynamically using .NET framework: a sample schema and XML
  • Generate XML Schema attributes dynamically using the .NET framework: explanation

  • 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: Working With Attributes - Generate XML Schema attributes dynamically using .NET framework: source code


    (Page 2 of 5 )

    In the previous section, I already listed a schema which we would like to generate dynamically.  The following is the complete VB.NET code needed to generate the previous schema:

    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 ctOrganization As New XmlSchemaComplexType
            eOrganization.SchemaType = ctOrganization
            Dim sqOrganization As New XmlSchemaSequence
            ctOrganization.Particle = sqOrganization
     
            Dim eEmployee As New XmlSchemaElement()
            sqOrganization.Items.Add(eEmployee)
            eEmployee.Name = "Employee"
            eEmployee.MaxOccursString = "unbounded"
     
            Dim ctEmployee As New XmlSchemaComplexType()
            eEmployee.SchemaType = ctEmployee
     
            Dim sqEmployee As New XmlSchemaSequence
            ctEmployee.Particle = sqEmployee
     
            Dim eName As New XmlSchemaElement()
            sqEmployee.Items.Add(eName)
            eName.Name = "Name"
            eName.SchemaTypeName = New XmlQualifiedName("string",
    "http://www.w3.org/2001/XMLSchema")
     
            Dim eAge As New XmlSchemaElement()
            sqEmployee.Items.Add(eAge)
            eAge.Name = "Age"
            eAge.SchemaTypeName = New XmlQualifiedName("int",
    "http://www.w3.org/2001/XMLSchema")
     
            Dim eID As New XmlSchemaAttribute()
            ctEmployee.Attributes.Add(eID)
            eID.Name = "ID"
            eID.Use = XmlSchemaUse.Required
            eID.SchemaTypeName = New XmlQualifiedName("int",
    "http://www.w3.org/2001/XMLSchema")
     
            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

    I purposefully excluded the “import” statements, as I already covered them in my previous articles.  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


       · Another article contributed for the series. Have it and enjoy. Any doubts (or...
     

    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 5 hosted by Hostway