• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ID and #REQUIRED or #IMPLIED

 
Anup Batra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have one question. When attribute_type is ID then #REQUIRED or #IMPLIED can be used as default. If suppose I have an element which appears more than once but without the ID value explicitly supplied (since IMPLIED will work here )then how could I refer to a particular element instance as there is no mean (ID value) with me to distinguish.
Can anyone explain me what XML do in this kind of situation.
Anup Batra
 
Luciano Queiroz
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to refer to this element by some attribute value. Otherwise, it will be treated equally as all other elements with the same name.
 
Anup Batra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
“You have to refer to this element by some attribute value. Otherwise, it will be treated equally as all other elements with the same name.”
Actually I want to ask about the uniqueness of the Attribute_Type ID here. What will be the value of att ID.
Anup Batra
 
Rakesh Gudur
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anup,
In this case if you want to refer to a particular element, then it is not possible. You can either loop through and handle the element you want to treat or compare with the element's content.
It's rather a design issue. You need to have an ID attribute in case you want to refer to an element specifically. It is like database referential integrity (PK).
Hope this helps,
Rakesh.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic