The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Help creating XSD document for XML validator

Hello, can someone give some hints to create the XSD code to validate something like this:

<xml version=1.0 encoding=utf-8>
<outer>
  <iner name="value">
    <list>
      <option name="O1">
          <pre name="first" />
          <pre name="second" />
      </option>
      <option name="O2">
          <pre name="irrelevant" />
      </option>
    </list>
  </iner>
</outer>

Outer and Iner can only appear once.

Thanks.
KrazyMane
Tuesday, November 13, 2007
 
 
Didn't you already ask this question in a slightly different way? http://discuss.joelonsoftware.com/default.asp?design.4.562629.8
John Topley Send private email
Wednesday, November 14, 2007
 
 
No, there I asked how I could do one thing, here I'm asking about several. Thanks.
KrazyMane
Wednesday, November 14, 2007
 
 
I suggest reading some tutorials on xsd first. w3cschools are
 a great source to start for beginners. you'll get nowere by
 this aproach. read the documentation first, ask questions later!
AZ Send private email
Wednesday, November 14, 2007
 
 
Hey, sorry, didn't want to give the impression that I want people to do this for me. Just looking for some guidance. Will read the tutorials and come back if there are problems. Thanks.
KrazyMane
Wednesday, November 14, 2007
 
 
I'm pretty sure tools like XmlSpy can create a schema from a sample of XML - this won't be perfect but will be a good place to start.
Arethuza
Wednesday, November 14, 2007
 
 
Visual Studio .NET can also generate a schema from sample xml if you're using that.
Ted Elliott Send private email
Wednesday, November 14, 2007
 
 
Isn't it more normal to start defining via XSD than to begin with XML?

Of course I suppose you might be handed XML samples by somebody who says "code to this" and won't share the schema.
Codger
Wednesday, November 14, 2007
 
 
"Isn't it more normal to start defining via XSD than to begin with XML?"

Probably but I did the XML and then I thought I could write a validator using C# specific code for that. I asked here on that other thread and people responses were about XSD, so I went to check those.

Will check those tools to see if they can write up a sample.

Thanks.
KrazyMane
Wednesday, November 14, 2007
 
 
I think Visual Studio can reverse engineer a schema from an xml file. Xml Spy can probably also do this. Do you have access to one of these tools?

Or perhaps there is some freeware out there that can do the same...?
Marc Jacobi Send private email
Thursday, November 15, 2007
 
 
Your XSD should come *before* the XML... it's essentially the contract describing how your XML should be structured.
KC Send private email
Thursday, November 15, 2007
 
 
Didn't even know about XSD.
KrazyMane
Thursday, November 15, 2007
 
 
Yes I use Visual Studio.
KrazyMane
Thursday, November 15, 2007
 
 
"Your XSD should come *before* the XML"

I know that, strictly speaking, that is correct. However, sometimes it is better to hand craft some sample XML to make sure it looks sensible and then create the XSD from these examples.

In my experience, this is more likely to produce XML that is easier  for people to work with.
Arethuza
Sunday, November 18, 2007
 
 
"Your XSD should come *before* the XML"

The schema-first approach is (also) more correct in my opinion. But how you get to the xsd is of no consequence. The xsd is the implementation of the schema. If you'd use pen and paper would you still say: "you should make the xsd first"?

Writing a sample xml and then generating the xsd is also a schema first approach. Some people think better in terms of how the data would exist in the application (the xml) and thats totally cool.
Marc Jacobi Send private email
Monday, November 19, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz