Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DTD and validation - RSS 0.91

 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The RSS 0.91 spec at
http://my.netscape.com/publish/formats/rss-spec-0.91.html
says that a <channel> is required to have <description>,
<language>, <link>, and <title> sub-elements, along with a
list of optional sub-elements.
The accompanying DTD expresses this constraint as follows:

which also appears to impose the additional requirements that the required
sub-elements appear exactly once, that at least one
<item> is present,
and that the other optional sub-elements appear no more than once.
Despite this, the following document validates successfully, with both "java sax.Counter -v"
and "java Validate":

even though it has two <language> tags, no <description> tag,
no <link>, no <title>, and no <item>s.
Is there a bug in the validator, or does the DTD not properly express the
requirement laid out in the specification?
[ October 02, 2002: Message edited by: Ron Newman ]
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order to verify that the "java sax.Counter -v" works, please test it with the following xml file -

My "java sax.Counter -v" gave the following output -
[Error] rss.xml:13:11: The content of element type "channel" must match "(language)".
C:\xml\rss.xml: 141 ms (4 elems, 1 attrs, 15 spaces, 13 chars)
Cheers,
Dan
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same here.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron,
All is fine.
Please look at the * at the end of the element definition.

So channel can have any number of language/title/description ... elements.
Go figure why they didn't use a simpler definition like -

Cheers,
Dan
[ October 03, 2002: Message edited by: Dan Drillich ]
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So are you saying that the DTD is incorrect, that it doesn't conform to the textual specification of this file format?
If I wanted to rewrite this part of the DTD to match the spec, how would I do so?
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I'm trying to say is that your understanding of the content model of the channel element is not correct. It is a very open model.
For example, all the following XML segments will be considered valid against this model.
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But my understanding of the content model comes from the spec at http://my.netscape.com/publish/formats/rss-spec-0.91.html . Look under <channel>, and you'll see that four sub-elements are listed as required: description, language, link, and title.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All that matters here is the content model of channel, which says that you can have -
Either title or description or link or language etc.
All the above can be present _any_ number of times, which means that two language elements in succession are valid.
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So why does the DTD not match the textual specification that it is derived from? How could I change it to match?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic