Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How it's to define hierarchical attributes in XML. In fact, I mean how to define attributes in such a way that wherever a specific attributes used, another one(s) could be used. For example, att1 could not be used before att2 and in every case that att1 is used, att2 is allowed.
Something like this:

XML
<elem att1="x" att2="y"/>:  is true

<elem att1="x" />:  is true

<elem  att2="y"/>: is not true
Posted
Comments
Kenneth Haugland 6-Feb-15 1:05am    
In my mind, hierarchical attributes does not look like that:
<elem name="A">
<elem att1="x">
<elem att2="y">

Eilia98 6-Feb-15 1:28am    
Maybe I misused hierarchical term; however I'm looking forward for the mentioned functionality. Any idea?
Richard MacCutchan 6-Feb-15 4:34am    
Attributes are linear not hierarchical. What problem are you actually trying to solve?
Eilia98 6-Feb-15 8:05am    
Maybe it is better to name them conditional attributes.I want to define attributes in such a way that wherever a specific attributes used, another one(s) could be used. Such as example presented in the question. In fact, I want to set order for attributes. Is there any way to do that?
Richard MacCutchan 6-Feb-15 8:52am    
That does not really make sense. XML is just text, it has no intrinsic meaning. You need to define the rules for your XML data, and then write the code to manage or interpret it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900