Questions for making a MySQL table from a DTD file
I have a dtd file which describes what columns my columns开发者_如何学编程 should have.
The problem is, it gives no info on what data type I should use for the columns, i.e whether INT, Varchar, or Text, and no info on the max length of the columns. In most places it says #PCDATA
which I believe simply means mixed data.
Is there a way for me to find out what data type and max lenghts I should use, or should I simply make a table full of Varchar (255)
s?
SGML is (in)famously lacking a type system, so there is no mechanized way to infer the correct type for any sort of element. Note that #PCDATA
doesn't mean "mixed data", but "parsed character data" -- an element with content #PCDATA
mustn't contain any other elements, but it can contain entity references (and in SGML it is subject to inclusion/exclusion exceptions, but those are not present in XML). "Mixed content" is something like (element1 | #PCDATA)
, which would be a lot harder to translate into a database schema.
Your best bet is to either deduce the content type from the element type names or from helpful comments in the DTD, and/or to inspect a series of documents in observe their usage pattern.
精彩评论