3

I am a beginner with XML. I can do DTD fairly well.

While learning about XSD and how to generate it, I found that all the tutorials available on Google and those on YouTube create XSD using third-party tools. For Windows they use either VB or xsd.exe tool.

Although handy, from a learner's point-of-view they are not good as I should know how to do it manually and later move on to automated schema generation.

My question is:

  • Are XSDs and DTDs always generated using third party tools ?
  • If they are handwritten, where can I find a good source of knowledge for it?
  • I am on a Windows machine, by the way :)

    An SO User
    • 24,612
    • 35
    • 133
    • 221
    • Hi, no you can write your own xsd-files and test them.Do you want something like extract xsd from xml? – tingel2k May 06 '13 at 10:06
    • @tingel2k No, I just want to create a schema for an existing XML document as practice. That's it. I made a DTD now I was moving to XSD. If that is what 'extraction' means :) – An SO User May 06 '13 at 10:07
    • To try out your hand-crafted XSD and DTD, I recommend XML Nanny. https://itunes.apple.com/us/app/xml-nanny/id423791387 – Thilo May 06 '13 at 10:07
    • XSD is XML file. You can create it by own but if you are tring to create XSD from XML file, it needs some tools. For more details on XSD follow http://docstore.mik.ua/orelly/xml/schema/index.htm link – Navin Rawat May 06 '13 at 10:08
    • You can write it by hand and test it against your file with http://xmlsoft.org/xmllint.html xmllint – tingel2k May 06 '13 at 10:09
    • @tingel2k That all answers my first question :) but what about the second one? :) – An SO User May 06 '13 at 10:11
    • take a look here http://www.w3.org/TR/xmlschema-1/ and here http://www.w3.org/TR/xmlschema-2/ but they are the full documentation/specification. But I think the best is here http://www.w3schools.com/schema/default.asp – tingel2k May 06 '13 at 10:14
    • @tingel2k if you can put all what you said in the comments as an answer then I will accept that – An SO User May 06 '13 at 10:15

    3 Answers3

    1

    1: You can write it by hand and test it against your file with xmllint

    2: Take a look here w3c doc-1 and here w3c doc-2 but they are the full documentation/specification. But I think the best is here xsd-tutorial

    tingel2k
    • 392
    • 1
    • 12
    1

    Writing a schema without any tools assistance at all is a bit masochistic. If you know the language reasonably well, a syntax-directed editor (such as oXygen) might be enough tooling for your needs. However, if you've got an instance document available that's reasonably representative of what you will encounter, then generating an XSD from the instance and modifying the generated XSD as required will save you a lot of effort.

    You definitely need a reference book on your desk. I use both van der Vlist and Walmsley.

    Michael Kay
    • 156,231
    • 11
    • 92
    • 164
    • You see, sir, people here abhor asking for reference to literature in the strongest possible ways. I do not know why but as far as I can remember books are the best source of knowledge. – An SO User May 07 '13 at 17:25
    • Hey can you help me with this one: http://stackoverflow.com/questions/16471559/how-do-i-add-namespaces-to-an-xsd – An SO User May 09 '13 at 21:43
    1

    I have written several by myself (with the assistance of some documentation) this link I actually prefer to do it myself, because the automatic ones may not work like I'd like them to (using Choices instead of sequences for example)

    Dan Drews
    • 1,966
    • 17
    • 38