BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
Schemas, xsd, xdr
Map Schemas using Model Groups
XSD Schema Mappings
General XSD Limitations
Extracting Schemas for Nested Classes
Creating Schemas from Assemblies
Strongly Typed .NET DataSet
XSD schemaLocation
Selecting Elements in Schemas
Specifying Namespaces
XSD targetNamespace
XSD Schemas
Convert XDR to XSD
Learn XSD Schemas .NET Tutorial
Conversion of genealogical files to XML with a DTD
AccessXML
Sorting by date without using a schema
Validating and enforcing a list of attribute values
Entity name support without DTDs
The Loss of Formatting When Adding a Schema
simple xml notepad
<< reBlogger
SEO >>

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/24/2008
Times viewed :176

 

Map Schemas using Wildcards

This section shows how we can map specific XML schema constructs to .NET classes with XML serialization attributes. All these mappings are automatically created by the XSD schema definition tool.

<any />

<xs:element name="car">

  <xs:complexType>

    <xs:sequence>

      <xs:element name="make"

        type="xs:string" />

      <xs:any namespace="##any"/>

    </xs:sequence>

  </xs:complexType>

</xs:element>

public class car {

  public string make;    

  [XmlAnyElementAttribute()]

  public System.Xml.XmlElement Any;

}

<anyAttribute />

<xs:element name="car">

  <xs:complexType>

    <xs:anyAttribute

      namespace="##any"/>

   </xs:complexType>

</xs:element>

public class car {

  [XmlAnyAttributeAttribute()]

  public System.Xml.XmlAttribute[]

    AnyAttr;

}

Hierarchies of Complex Types

<xs:complexType name="vehicle_t">

  <xs:sequence>

    <xs:element name="make"

      type="xs:string" />

    <xs:element name="model"

      type="xs:string" />

  </xs:sequence>

</xs:complexType>

<xs:element name="vehicle"

  type="vehicle_t" />

<xs:complexType name="car_t">

  <xs:complexContent>

    <xs:extension base="vehicle_t">

      <xs:sequence>

        <xs:element name="VIN"

          type="xs:string" />

      </xs:sequence>

    </xs:extension>

  </xs:complexContent>

</xs:complexType>

<xs:element name="car"

  type="car_t" />

[XmlIncludeAttribute(typeof(car_t))]

[XmlRootAttribute("vehicle",

    IsNullable=false)]

public class vehicle_t

{

  public string make;

  public string model;

}

[XmlRootAttribute("car",

    IsNullable=false)]

public class car_t : vehicle_t

{

  public string VIN;

}

The All Model Groups

<xs:element name="foo">

  <xs:complexType>

    <xs:all>

      <xs:element name="bar"

        type="xs:string" />

      <xs:element name="foobar"

        type="xs:int" />

    </xs:all>

  </xs:complexType>

</xs:element>

public class foo {

    public string bar;

    public int foobar;

}

Default Values

<xs:element name="Car">

  <xs:complexType>

    <xs:sequence>

      <xs:element name="make"

        type="xs:string"

        default="Ford" />

    </xs:sequence>

    <xs:attribute name="year"

        type="xs:string"

        default="2002" />

  <xs:complexType>

</xs:element>

public class Car

{

  [System.ComponentModel.

    DefaultValueAttribute(

    "Ford")]

  public string make="Ford";

  [XmlAttributeAttribute()]

  [System.ComponentModel.

    DefaultValueAttribute("2002")]

  public string year="2002";

}


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

An immediate job opportunity as a B
Software Developers Needed in Charl
Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C

View all Jobs (Add yours)
View all CV (Add yours)



answering service
fax server
swimming pool contractor
teleconferencing
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP