Forum Stats

  • 3,875,869 Users
  • 2,266,977 Discussions
  • 7,912,360 Comments

Discussions

A generic XML DTD

843834
843834 Member Posts: 49,972
edited Jul 25, 2001 2:10PM in Java Technology & XML
Hi
I am a newbie to XML and I have a question on XML/Java, hopefully, you guys would be able to give me some pointers to solve this problem.
Here is the scenario. I need to design (might have to implement as well) a set of Java libraries that can retrieve data (basically, it's some kind of contents, it can be anything, more on this later) and base on the data I retrieved, I would generate a html file (which contains those contents and have the contents displayed).
Those data (contents) I talked about earlier could be some news item, could be lottery results, could be a travel guide, could be anything. Those data would originally come from a XML file and then store into a database table. (or could just be in a file if there isn't much data). Either way, my programs should be able to read the data from the database/files and somehow "decrypt" it.
Now, my problem is since the data could contain any kind of data, how do I define a DTD that is so generic that can treat all kinds of contents as the same. By that, I mean, e.g if it was a book review article, it might contain the book's name, the author, the review, the review date...etc, I would imagine that the DTD would contain tags like TITLE, AUTHOR, REVIEW DATE, REVIEW...etc. With all these data, they would be stored into a table, may be just a text field in that table. And then my programs would read from that field and break up those tags and display them accordingly (generate a html file) . But what if it is a lottery result, then the DTD that I defined earlier (for news) would not be applicable for the lottery result content. That means, in order to treat everything as just pure content, I can only have a tag, say content, and for the book review article, this tag would just wrap everything into itself (from the book's name, author....etc) and for the lottery results, the content tag would just contain the numbers. I must say, I have minimal XML knowledge, so please correct me if I am wrong here. But again, how would you define a DTD for such scenario? Is it possible to define such a DTD? Not to mention the style of the contents.......Please, I need help. THx
ForeverJava
anywhere else is a better place for XML forums?


Comments

  • 843834
    843834 Member Posts: 49,972
    You certainly could water down a DTD to handle all of the different types of events that you are encountering. At this point though the DTD becomes so permissive that it is almost of no use.

    If you are using an XML parser to get at the data it will have to be well-formed. You might as well turn validation off, if the structure is so loose.

    Can you apply a different DTD based on the type of request that is coming back? For example if it's lotto results apply lotto.dtd if it's scores apply scores.dtd, etc.

    You could probably even wrap a root level around the entire document that is consistent and then require one of the data type (lotto, score, etc.) levels next and then proceed.

    Hopefully some of this makes sense-
    -Mike
This discussion has been closed.