Solved

XSD Advice

Posted on 2013-10-24
3
193 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

705 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