in reply to XML and DTD and Twig...

So, if there are groups like "goober" and "blurch" and "frang", each having a separate "alias" to the "real xmldb.cgi" script, and each having a distinct xml structure, is it the case that all "goober" records have the same structure, and all "blurch" records share some other structure, etc?

If that's the case, then I think a single DTD file per group would be best. And when you use your main script to access ALL groups, I would expect that you just need to create a new Twig object for each group, and access the DTD for that group to know about its structure. (You shouldn't need to add structure to the XML data in order to describe the structure, though perhaps this might not be a bad idea -- assuming it's done consistently across all groups/records so that they all have something useful in common, regardless of anything else.)

The only way it would make sense to have the DTD included with every record is if every record could potentially have a different structure, regardless of what group it's in. (For that matter, I wonder about needing DTD's at all -- I thought the one of the design goals of XML was to make the markup parseable without requiring any "ad hoc" DTD a priori -- in contrast to the more cumbersome SGML.)

Replies are listed 'Best First'.
Re^2: XML and DTD and Twig...
by lee_crites (Scribe) on Nov 12, 2004 at 20:47 UTC

    In my case, each file will be one record. That record could belong to any "database" I have. I have defined (for myself) certain fields (e.g. 'name' or 'city') that have predefined meaning and a common layout. I put that layout into a global INI type file that all scripts will access. When a new (and unique) field is added to any database, I stick that into the global file as well. So there is one file (voc.xml) that has every field name and all of it's particular layout definitions.

    What I am doing is to write a single display and edit CGI script. It will read in the voc.xml file, and then somehow (automagically) know what to do with the record. This worked just fine before the migration to XML, so I know the process works, I'm just trying to find the "best practice" for the XML world in duplicating it.

    It seemed to me that the perfect place to do this was in the DTD. Each database would have a DTD file that contained a list of all of the fields it used, etc. But how do I tie the record I am processing to the DTD that relates to it? The internal DTD info seemed like the perfect location for that as well. But XML::Twig didn't process it correctly, and when I looked, I found out that this was a known problem.

    But my philosphical question remains: what's the best practice for linking the data file to the DTD file? I can read the documentation, but so far I haven't really gotten a good feel for what is really being done by those folks who are actually using this.

    Lee Crites
    lee@critesclan.com