• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

contradicting statements about body-content in a tld

 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

On p508 of Head First Servlets it says "For a custom tag, the body-content element inside the tag element of a TLD is mandatory!" The exclamation point is theirs, not mine.

But on p3-46 of the JSP Specification 2.0, where the DTD for the TLD file format is shown, it says for the body-content element "This element is optional; the default value is JSP".

Now, I can see why a simple tag's TLD file would need a body-content element, because the default specified in the spec is not allowed.

But that leaves classic tags. Is body-content mandatory for classic tags?

Thanks,
John
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But on p3-46 of the JSP Specification 2.0, where the DTD

DTD ? The TLD uses an XML Schema, described at JSP.C.1XML Schema for TLD, JSP 2.0. You'll see that the body content is mandatory.
 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christoph.

A DTD is a file that describes an XML schema. You will find the the DTD for the TLD XML schema beginning on p 3-41 of the JSP 2.0 Spec. The section is title "JSP.C.2DTD for TLD, JSP 1.2". In it specifies that body-content is optional (p 3-46).

But since all your other helpful information has been correct, I believe you when you say it is mandatory.

Thanks a bunch,
John
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A DTD is a file that describes an XML schema.
Not quite---perhaps I've missed something, but AFAIK, DTD is an older alternative to XML Schema. In fact, a DTD is an example of an XML schema definition, just not an XML Schema.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The section is title "JSP.C.2DTD for TLD, JSP 1.2

Be careful, you are studying for JSP 2.0, not 1.2. Same for servlets. You can still see the old Servlets 2.3 DTD in the spec, but you have to look for Servlets 2.4's XML Schema instead.

About what an XML Schema (with big 'S') is, you can check Wikipedia.
 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both of you for your clarification. Turns out my book on XML was written in 2003. It doesn't mention "XML Schema". I'll read up about it.
 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.

Although this thread is long dead, I just want to share for any future readers that I have discovered through my own testing that body-content is only mandatory for simple tags. Classic tags can omit that element in their tld.

But don't simply take my word for it (or anyone elses for that matter), try it yourself...

John
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic