File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes DTD content model question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "DTD content model question" Watch "DTD content model question" New topic
Author

DTD content model question

Jane Somerfield
Ranch Hand

Joined: Jul 20, 2002
Posts: 192
Can anyone tell me what is wrong with following:
<!element Book ((Title, Author) | (Title, Price))>
Thanks.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12266
    
    1
Shouldn't that be
<!ELEMENT
instead of
<!element
Bill
Shoba Ramachandran
Ranch Hand

Joined: Mar 29, 2001
Posts: 68
Here is the correct syntax
<!ELEMENT Book ((Title, Author) | (Title, Price))>
element should be in uppercase
-Shoba
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Gee, this is a good question!
It may look simple, but it is quite deep and the best thing, when we go the next level of depth "problem" switches to "non-problem" and vice versa.
I believe that if you correct letter case as Mr. Brogden suggested, it will fix the problem. Um... Not really.
Next level of depth bring us to XML specification, which claim
<!ELEMENT Book ((Title, Author) | (Title, Price))>
to be "non-deterministic content model"
"This requirement is for compatibility with SGML (which calls deterministic content models "unambiguous"); XML processors built using SGML systems may flag non-deterministic content models as errors."

IBM 140 mock exam had a question on it,
<!element Customer ((Name, Ship-to-address) | (Name, Bill-to-address))> was said to be an error.
However, if we go to the next level of inquiry, we will learn that parsers are quite happy with such syntax and do not report any problem. So is it an error or not?
Here is what Joe English thinks about it:
> I understand that the XML 1.0 spec prohibits non-deterministic (or,
> ambiguous) content models (for compatibility, to be precise).
> Are all xml 1.0 compliant xml processing software required to reject
> DTDs with such content models?
No: a processor can ignore the DTD entirely and still be compliant. And since the prohibition against non-deterministic content models appears in a non-normative appendix, I would presume that conforming DTD-aware processors are not required to detect this condition either. Even in full SGML, ambiguous content models are a "non-reportable markup error", i.e., parser don't need to detect this condition.
http://www.oasis-open.org/cover/ambiguousContentModels200101.html
Now if we want to go even deeper and learn more,
"In fact, there is a very simple algorithm available that handles non-determinism just fine (it doesn't require you to construct a NFA and then do the subset construction). See http://www.flightlab.com/~joe/sgml/validate.html (TREX uses a variation on this).
Can any non-deterministic content model be converted to deterministic? The answer seem to be "no".
"Sam Willmott from OmniMark released a white paper on content model algebra in the early nineties. He concluded that there was only one content model that cannot be disambiguated and I have yet to see proof to the contrary. The model is:
(x, (y, x)*, y?)
"
Well, here I stopped, but if you still didn't have enough, you can go and read popular among content model developers Sam Wilmott's Content Model Algebra. I wish I could enjoy such a prose... :roll:
Here is a nice collection of links for your examination:
http://www.oasis-open.org/cover/topics.html#ambiguity
Now back to your question, ELEMENT should solve the problem, yes.
[ July 23, 2002: Message edited by: Mapraputa Is ]

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: DTD content model question
 
Similar Threads
PASSED SCJP1.4 with 83%
when to use commit (for result set?)
Which technology is responsible for managing web services transactions?
Can I run resin and apache on two machines?
I am confused by the File.Some one advise me materials to lern.