Forums Register Login
Query on use of inheritance using restriction
whats the real use of restriction?

Why cant we just declare a new type? I dont understand...

Could someone please help

Originally posted by Abhishek Dharwadkar:
Why cant we just declare a new type?

Of course you can.

In fact Nicolai Josuttis states in SOA in Practice: The Art of Distributed System Design (p44):

Based on my own experience (and others), I recommend that you have a basic set of fundamental types that you can compose to other types (structures, records) and sequences (arrays). Be careful with enumerations (an anachronism from the time when each byte did count - use strings instead), inheritance and polymorphism (even when XML supports it).

However the concept of restriction is supposed to help eliminate duplication from the schema.

Also restriction isn't inheritance in the polymorphic sense - i.e. you can't always use the derived type in place of the parent-type because the derived type is more constrained than the parent type. Restriction is used to create new types by placing additional constraints on an existing type - the existing type is often a base XML type. For example:

a lower case alpha string with at least 6 but no more than 8 letters

an integer with an allowable range of 0-99

constrained temperature types
Thanks Peer
Thanks Peer for such a good explanation

This thread has been viewed 965 times.

All times above are in ranch (not your local) time.
The current ranch time is
Nov 19, 2018 04:56:58.