XML
  Home arrow XML 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 
Mobile Linux 
App Generation ROI 
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? 
XML

Generating XML Schema Dynamically Using VB.NET 2005: Essentials
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 28
    2006-02-06

    Table of Contents:
  • Generating XML Schema Dynamically Using VB.NET 2005: Essentials
  • Understanding the dynamic generation of XML Schema using the .NET framework
  • Generating XML Schema dynamically using the .NET framework: complex type
  • Understanding the dynamic generation of complex type in XML Schema

  • 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


    Generating XML Schema Dynamically Using VB.NET 2005: Essentials - Understanding the dynamic generation of XML Schema using the .NET framework


    (Page 2 of 4 )

    This section explains the code fragment listed in the previous section.  Let us examine it part by part.  First consider the following:

    Imports System
    Imports System.Xml
    Imports System.Xml.Schema

    The above makes class libraries (related to XML) available for our application.  We shall clear the textbox information using the following statement:

    Me.TextBox1.Text = ""

    Proceeding further, we have the following statement:

    Dim schema As New XmlSchema()

    The above statement really starts our XML Schema.  It creates an object (“schema”) of type “XmlSchema.”  The class “XmlSchema” basically exists in the namespace “System.Xml.Schema,” which resides in “System.XML.dll” assembly.  This would indirectly add the top most processing instruction, which defines the XML document version, and so on.

    Once a schema object is created, we can start adding our own elements, attributes, processing instructions, comments, and so on to the same schema object.  Further proceeding, we have the following:

    Dim elementOrg As New XmlSchemaElement()

    The above statement creates a simple XML Schema element (but no descriptions of the element yet!).  Further proceeding we have:

            schema.Items.Add(elementOrg)
            elementOrg.Name = "Organization"
            elementOrg.SchemaTypeName = New XmlQualifiedName
    ("string", "http://www.w3.org/2001/XMLSchema")

    The first statement from the above code fragment adds the element “elementOrg” to the schema (which we already created at the top).  The second and third statements determine the characteristics of the element “elementOrg.”  The second statement assigns the element name and the third defines the “data type” with respect to the definitions available at http://www.w3.org/2001/XMLSchema.  Further proceeding, we have the following 

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

    The above two statements are used to define the namespace to which our schema is adhered. Further proceeding we have the following:

            Dim sw As New IO.StringWriter
            schema.Write(sw, nsmgr)
            Me.TextBox1.Text = sw.ToString

    The above code fragment creates a string writer where the schema is generated (using the namespace we defined earlier).  Once the schema generation is complete we finally display it using the last line.

    More XML Articles
    More By Jagadish Chaterjee


       · Hello guys, dig into creating dynamic XML Schemas using vb.net 2005 using this...
     

    XML ARTICLES

    - More on Triggers and Styles and Control Temp...
    - Looking at Triggers with Styles and Control ...
    - A Closer Look at Styles and Control Templates
    - Styles and Control Templates
    - Properties and More in XAML
    - Elements and Attributes in XAML
    - XAML in a Nutshell
    - Importing XML Files into Access 2007
    - Using MSXML3.0 with VB 6.0
    - MSXML, concluded
    - MSXML, continued
    - MSXML Tutorial
    - Generating XML Schema Dynamically Using VB.N...
    - XSL Transformations using ASP.NET
    - Applying XSLT to XML Using ASP.NET





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT