Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to XML Question

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anything that establishes an unique relation between an attribute and the entity to which that particular attribute belongs?

I raise this question is because the application on which I am working transforms an XML file to a String (using XMLStream reader). The code then searches all the attributes one by one in that String and finds the position index of each of the attributes.

However, many entities can share the same attribute.

By the way, I also have the position index of each of the entities in that String.

Thanks for your time and insight.
 
Paul Clapham
Sheriff
Pie
Posts: 20958
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The XML Recommendation specifies that an attribute belongs to an element.

But I'm not sure how that relates to your question. It sounds to me like you aren't using an XML parser and so you're having trouble establishing that relationship? Or am I misunderstanding the question?
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not use the proper terminology in my question. I should not use the term "entity". Let me re-word my question:

Is there anything that establishes an unique relation between an attribute and the element to which that particular attribute belongs?

I raise this question is because the application on which I am working transforms an XML file into a String (using XMLStreamReader). The code then searches all the attributes one by one in that String and finds the position index of each of the attributes.

However, many elements can share the same attribute.

By the way, I also have the position index of each of the elements in that String.

I hope that I have clarified my question. Thank you.
 
Paul Clapham
Sheriff
Pie
Posts: 20958
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the fact that the attribute is inside the start tag of the element which establishes the relationship. If that's what you mean -- I'm still mystified by the question in general.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In XML-based languages, attributes are not "shared" by elements. The same attribute "name" may be used by more than one element in a language, but this does not mean they are "sharing" the same attribute.

For example, I can create a book element that has an ID attribute. And I can create a chapter element that also has an ID attribute. Here the book element and the chapter element are not "sharing" an ID attribute. Each ID attribute belongs to only a single element.

To make markup language design a little easier, the attribute declarations in a DTD or XML schema may be "re-used". This does not mean that the elements are sharing the same attribute however. The declaration is simply referenced twice, once for each element (in memory).

Hope this helps!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic