BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
Schemas, xsd, xdr
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
Schemas using DBMS_XMLQuery Package
Tips for Designing a DTD - Part 1 of 4
Tips for Designing a DTD- Part 2 of 4 : Semi-Structured Documents
Tips for Designing a DTD- Part 3 of 4 : Database Oriented Data
Tips for Designing a DTD- Part 4 of 4 : Object Oriented Data
Getting the value of an element with optional subelements
XML Code Generator: Generating Wrapper Classes from an XML Schema
<< 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 :263

 

XSD schemaLocation

NOTE: The XSD tool does not honor the schemaLocation hint on the <import> tag. You have to list all referenced schemas explicitly on the command line. This is not necessary for schemas referenced by an <include> tag.

You probably noticed that both schemas previously listed declared a top-level element car. By default, the tool generates the class corresponding to the type the first time it encounters an element definition referencing the complexType. In this example, the first element to reference the type is the car element in the car.xsd schema hence xsd.exe creates a class definition referencing the urn:christoph-cars namespace:

7           Listing C.7 Car class generated from the car schema.

[System.Xml.Serialization.XmlTypeAttribute(

  Namespace="urn:christoph-cars")]                       | #1

[System.Xml.Serialization.XmlRootAttribute("car",        |   | #2

  Namespace="urn:christoph-cars", IsNullable=false)]     |

public class car_t {                                         | #3

  [System.Xml.Serialization.XmlAttributeAttribute()]

  public string make;

  [System.Xml.Serialization.XmlAttributeAttribute()]

  public string model;

  [System.Xml.Serialization.XmlAttributeAttribute()]

  public string year;

}

(annotation) <#1 The attributes specify the namespace from the schema in car.xsd.>
(annotation) <#2 The XmlRootAttribute maps the car_t class to a car element in an XML document. >
(annotation) <#3 The class name is based on the type name, not the element name.>

If we need to create a car class corresponding to the car element from the urn:christoph-garage namespace we have to explicitly select the namespace with the /u switch:

xsd.exe car.xsd garage.xsd /c /l:CS /u:urn:christoph-garage

When this switch is present on the command-line, the tool will extract all top-level elements belonging to the specified namespace. The generated car class now maps to the car element in the garage schema:

[System.Xml.Serialization.XmlTypeAttribute(            

  Namespace="urn:christoph-cars")]                     

[System.Xml.Serialization.XmlRootAttribute("car",      

  Namespace="urn:christoph-garage", IsNullable=false)] 

public class car_t {


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
online fax service
swimming pool contractor
teleconferencing services
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