Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Generating Restrictions in XML Schema Dyna...
Moblin
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 
Moblin 
JMSL Numerical Library 
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 Restrictions in XML Schema Dynamically Using VB.NET 2005: Preliminaries
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2006-03-15

    Table of Contents:
  • Generating Restrictions in XML Schema Dynamically Using VB.NET 2005: Preliminaries
  • Restrictions (or constraints) in XML Schema: VB.NET sample
  • Restrictions (or constraints) in XML Schema: explanation
  • Extending the previous restriction with minExclusive
  • Differences between xxxExclusive and xxxInclusive

  • 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

    Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!

    Generating Restrictions in XML Schema Dynamically Using VB.NET 2005: Preliminaries - Extending the previous restriction with minExclusive


    (Page 4 of 5 )

    I gave an example covering the “Age” element previously.  It is not going to be a complete solution yet.  We specified only the maximum value (and forgot about the minimum value).  So, let us make tiny modifications (especially for the “Age” element) to our schema so that it looks like the following, which contains two facets now:

    <xs:element name="age">
          <xs:simpleType>
                <xs:restriction base="xs:integer">
                      <xs:minExclusive value="0" />
                      <xs:maxInclusive value="100" />
                </xs:restriction>
          </xs:simpleType>
    </xs:element>

    Within the above XML Schema, I managed to have two facets be implemented.  Now, with the above two facets we tightly restrict the “Age” element to have a value only between 1 and 100.  Now, let us see how we can achieve the same dynamically using .NET.

    You can modify the code fragment presented in the previous sections as follows:

    Dim restriction As New XmlSchemaSimpleTypeRestriction()
            simpleType.Content = restriction
            restriction.BaseTypeName = New XmlQualifiedName
    ("integer", "http://www.w3.org/2001/XMLSchema")
            Dim minExclusive As New XmlSchemaMinExclusiveFacet()
            restriction.Facets.Add(minExclusive)
            minExclusive.Value = "0"
            Dim maxInclusive As New XmlSchemaMaxInclusiveFacet()
            restriction.Facets.Add(maxInclusive)
            maxInclusive.Value = "100"

          

    And that would achieve what we desired.  Once you execute the above code, you should be able to see the following output of the XML Schema:

    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="Organization">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" name="Employee">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Name" type="xs:string" />
                  <xs:element name="Age">
                    <xs:simpleType>
                      <xs:restriction base="xs:integer">
                        <xs:minExclusive value="0" />
                        <xs:maxInclusive value="100" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute name="ID" type="xs:int"
    use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>



    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hi, now you can work with restrictions in XML Schema using VB 2005. Any feedback is...
     

    VISUAL BASIC.NET ARTICLES

    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...
    - Creating and Drawing a Game Map in VB.NET
    - 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...





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