Solved

XSD Advice

Posted on 2013-10-24
3
181 Views
Last Modified: 2013-11-07
Hi,

I’m after some advice regarding XSDs.  I have created a class that extracts data from a database and exports it to an XML document.
I have now been asked to produce a XSD.  I noticed that in visual studio 2010 there is an option to open a XML and automatically generate a XSD document.  Is this advisable?

I suppose if that method is used I should make sure that all elements are populated with the correct data?

Any advice appreciated?
0
Comment
Question by:andyw27
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39599238
Have you tried to use that option to generate an XSD, so that you can see what the output is.  You should be able to use an XSD to validate any XML to see if it meets the schema requirements.
0
 
LVL 19

Accepted Solution

by:
drichards earned 500 total points
ID: 39602237
The auto-generated XSD is a good starting point, but if your XML is more flexible than your sample XML then you will need to fix it up as it will not be fully correct.

For example, you need to check min/maxOccurs on elements, check  attribute types, create enumerations for values that are enumerations, create substitution groups or derived types if necessary, etc.  The generated schema will match the XML used to produce it but if your input XML did not represent all possible options then the schema will be deficient.

Examples of the type of things that are missed:
1. Optional elements or attributes that were not in the XML used to produce the schema
2. More complex productions like sequence of choice will not be correctly inferred
3. An attribute value that is supposed to be string may come out as a numeric type if only digits are present.

You get the idea.  The generated schema is still a good place to start in most cases, though, and if your XML is really simple the generated XSD may be entirely adequate.
0
 

Author Comment

by:andyw27
ID: 39629932
Thanks that's great.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now