?
Solved

XSD Advice

Posted on 2013-10-24
3
Medium Priority
?
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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