views:

85

answers:

2

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).

A: 

There are tools out there that will help you generate DTD or XSD for sample XML (XML Spy has served me well in the past).

I don't know of anything that will do that based on XSLT, since it's rather hard to say what will come out without having a source XML, and once you have that you might as well just put the resulting XML through the more common tools.

Do you have a sample of the XML or XSLT you're using?

Timothy Walters
+2  A: 

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.

Workshop Alex