I’m working on an application that uses XSLT to transform XML generated by JSP. At the moment no DTD exists to describe the XML format the XSL expects. Does anyone know of a tool that can generate a DTD from a XSL describing the input the XSL is expecting? Is this even feasible?
Result: The accepted answer pointed out that this is in fact not possible. I ended up using some trickery to write the XML generated by the JSP to disk and use those as input to Trang http://www.thaiopensource.com/relaxng/trang.html (that can generate one DTD from many XML sources).
Altova XmlSpy can generate a DTD from an XML file. But a tool that can analyse an XSLT file to determine the XML structure is near to impossible. Basically, some XPath notations are too generic to be converted. For example,
//*[@name='Apples']/@*would select all attributes from elements that have an attribute with value ‘apples’. Basically, this means that any element can have name attributes.