• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Attribute precedance in elements

 
Ujwala Kawalay
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If we have the following code:-
<element name="myelem">
<complexType>
...
<attributeGroup ref="myattgrp" />
<attribute name="myatt" type="string" />
</complexType>
</element>
<attributeGroup name="myattgrp">
<attribute name="myatt" type ="integer" />
</attributeGroup>
What will be the type of attribute assigned to element myelem? will it be of type string or integer? What are the rules for attribute precedence?
Appreciate your responses
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
There is a problem with your question
I think the question is not valid as the schema you have defined is not valid

I put this in XML spy to validate it. It says that this schema is not valid. Hence your question is not valid.
Hopefully I am right as I am new to XML
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
When I rename the "myatt" attribute the validation takes place sucessfully.
 
Ujwala Kawalay
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,
I know that the piece of schema that I posted was not valid by itself.(You need the xml declarations, schema namespace etc etc). I was trying to draw attention only the relevant section of the schema declaration.
I read somewhere in w3c specs that one can override attribute values in attributeGroup by declaring additional attributes with same name. But I was not sure of the context and hence wanted to confirm the same.
Also, I am a little spectical of XML SPY, as it validated a schema with an element having 2 attributes with same name and type . (I read in w3 spec that an element cannot have attributes with same name,-- unless the spec has been changed recently).
I think the implementations of w3 specification will vary from one IDE to another. SO, in case of such conflicts I think its better to believe w3c spec than any IDE.
Regards
Ujwala
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic