In a new post to his blog Kore Nordmanntalks about a tool he's developed that will "learn" XML schemas based on a document it's given. The tool, the XML-schema-learner, makes it as simple as a one-line command to generate the DTD file and transform it into a schema.

He includes an example XML definition and the resulting DTD that the tool generates from it, defining each of the elements and attributes each can have. The tool can then take this DTD file and generate an XSD file, creating complex and simple types that match the original data.