• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

finalDefault="#all"

 
Siva shanmugam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The effect of specifying the finalDefault attribute is equivalent to
specifying a final attribute on every type definition and element declaration in the schema.
If you define a finalDefault attribute with "#all" as a value
you can't derive a new complexType or a simpleType from exiting complexType
and simpleType,that are defined in that schema.
But what is the use of defining an element with final attribute which can have
a value restriction or extension or #all ?
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you mean to talk about the final attribute defined for the types and not the element. There can be a lot of practical scenarios as to where this can be helpful. I try to imagine one here. There may be a scenario wherein we would like the baseType to be partially frozen (final = #restriction, say).
Why would we do so??
For example, the base type is a simpleType restricting an xsd:integer to be a nonNegativeInteger. You may not want a derivedType to further restrict this baseType to be an integer within bounds (say 1-100).
If we allow the derived type to do that, the problem is that,in the document instance, the derived type content can always substitute for the element content (unless blocked) of the baseType and this additional restriction(1-00) is something which we might not want simply by the virtue of defining the element to be of baseType.
I hope this clarifies your doubt a little. I would like to hear from guys who worked on more practical things for better explanation.
 
Siva shanmugam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Jayadev & Ranchers,
my question is ,
"Why do we need to use final attribute in element declarations ?"
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Siva,
There is no final attribute for element to the best of my knowledge. If you want that no sub-elements should substitute for the parent element, you should define a block="substitution" for the element. If you donot want any instance of the element, you should have abstract="true".
Hope this helps.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jayadev
I think your answer is conflicting to this quote from http://www.w3.org/TR/xmlschema-0/
The restriction value of the final attribute prevents derivations by restriction. Preventing derivations at all, or by extension, are indicated by the values #all and extension respectively. Moreover, there exists an optional finalDefault attribute on the schema element whose value can be one of the values allowed for the final attribute. The effect of specifying the finalDefault attribute is equivalent to specifying a final attribute on every type definition and element declaration in the schema.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rosseane and Siva,
You are right. The only thing i'm not being able to figure out is the meaning of "final" attribute for an element. What does it mean? Does it mean that the element cannot be extended, etc.? What do we mean by extending an element? Can you please explain this.
Thanks in advance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic