• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

New to XML Question

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic