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

ID attribute DTD

 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one confusion regarding the ID
ID has to be unique for a particular element or for whole of the document.

Suppose i have a <Teacher> element with a ID attribute TeachID
and a
<Student> element with a ID attribute StudentID

now is it legal to use same id for TeachID and StudentID
<root>
<Student StudentID="001"/>
<Student StudentID="002"/>
<Student StudentID="003"/>
<Teacher TeachID="001"/>
<Teacher TeachID="002"/>
<Teacher TeachID="003"/>
</root>
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andy,
ID MUST be unique in an xml document. It does not matter if ID attribute is present in different elements.

Good Luck,
Satish.
 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Satish
 
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!