aspose file tools*
The moose likes XML and Related Technologies and the fly likes New to XML Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "New to XML Question" Watch "New to XML Question" New topic
Author

New to XML Question

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

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

Joined: Nov 19, 2000
Posts: 1309
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
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

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

Joined: Apr 16, 2008
Posts: 2187
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New to XML Question