I'm having a head-scratching time trying to work out how best to design my XML. Questions like should I use: <action scope="global"> blah .. </action> or: <action> <scope>global</scope> blah .. </action> or: <action> <scope>global</scope> <content> blah .. </content> </action> or: <global-action> blah .. </global-action> All of these are semanticaly equivalent, but I want to make my XML as amenable to different processing methods as possible and reasonably flexible for unknown future requirements. Does anyone know of any websites or books which discuss issues like this?
Well, I'm pretty new to XML and haven't really done much research on it, so I can't help you with websites or books. But if you want my rather uninformed opinion anyway, I like the first construct best. <action scope="global"> blah .. </action> As long as a given action can have only one scope, and that scope can be represented by a simple string, this is all you need IMO. And all the "blah..." is clearly modified by the scope "global". <action> <scope>global</scope> blah .. </action> This one could be useful if your concept of scope is more complex - e.g. if you want to define the scope to include modules A and C, but not B: <action> <scope>module A</scope> <scope>module C</scope> blah .. </action> But this is longer obviously. And it's not as obvious to me whether "blah..." is modified by one, both, or neither of the scope elements. It looks like "blah..." is outside the scope of either <scope>. Maybe there's a way in XML to specify whether this is the case or not; I dunno. <action> <scope>global</scope> <content> blah .. </content> </action> Again, is the content modified by the scope? It doesn't look like it, IMO. Do you want to be able to have more than one <content> as well as more than one <scope> inside an <action>? If not, this seems like overkill. Also, I tend to think that the "content" of the <action> is already implicitly (or explicitly?) defined as whatever is in between the <action ...> and the </action>. <global-action> blah .. </global-action> This could work. But will there be other types of actions, e.g. <local-action>? Will they be similar in most ways? I'd want to keep their common behavior in a single <action> element. But that's my OO thinking - I'm not sure how necessary it really is here.
"I'm not back." - Bill Harding, Twister
posted 19 years ago
Thanks for the reply. I was beginning to think no one else even reads the XML forum. These are just the kind of many-possible-answers questions I keep bumping into with XML. For the moment I have gone with a version of the first option. I hope it was the right choice.
While browsing a local bookstore, I came across "Structuring XML Documents" by David Megginson. This seems to have a fair amount to say about this sort of thing, and has pretty good reviews at amazon. Probably worth checking out.