Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

DTD - IDREF

 
lavanya Ananth
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's me again. Pls rad thru the DTD below.

<! ELEMENT bookstore ( shipping+, book+, officesupplies+) >
<! ELEMENT shipping ( duration) >
<! ATTLIST shipping shipID ID #REQUIRED >
<! ELEMENT book ( title , author) >
<! ATTLIST book bookno ID #REQUIRED shippedBy IDREF #IMPLIED >
<! ELEMENT duration ( #PCDATA) >
<! ELEMENT title ( #PCDATA) >
<! ELEMENT author( #PCDATA) >

If i wanted to have an attribute for title , say ISBN which refers to book no, how do i specify it? Is the declaration below correct?

<! ATTLIST title ISBN IDREF #REQUIRED >

How does the parser know which ID the above decl references?

I am also assuming that a single element can have two attributes that are unique. How do we then use IDREF to refer to a particular unique attribute?


Thanks in Advance,
Lavanya
 
Hari Vignesh Padmanaban
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by lavanya Ananth:

If i wanted to have an attribute for title , say ISBN which refers to book no, how do i specify it? Is the declaration below correct?

<! ATTLIST title ISBN IDREF #REQUIRED >

It is perfect


How does the parser know which ID the above decl references?

I am also assuming that a single element can have two attributes that are unique. How do we then use IDREF to refer to a particular unique attribute?



According to the DTD specifications, there may be only ONE ID attribute for each element type

So I guess that the DTD parser would know which one to look for

Hope that helps
[ December 28, 2005: Message edited by: Hari Vignesh Padmanaban ]
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!