- From: Curt Arnold <carnold@houston.rr.com>
- Date: Fri, 16 Jan 2004 01:48:28 -0600
- To: www-dom-ts@w3.org
Over the past few days, I've also added 48 tests for TypeInfo.isDerivedFrom. I had commented that I thought that the spec was underdocumented, especially when dealing with derivation trees that involve multiple method of derivations. Basically, the tests reflect the following algebra: If <simpleType name="b"> <restriction base="a"/> </simpleType> (or equivalent complexType> then: b.isDerivedFrom(otherType, method) = ((method & METHOD_RESTRICTION != 0) && otherType == a) || a.isDerivedFrom(otherType, method) If <simpleType name="c"> <union memberTypes="a b"/> </simpleType> Then: c.isDerivedFrom(otherType, METHOD_RESTRICTION) = a.isDerivedFrom(otherType, METHOD_RESTRICTION) && b.isDerivedFrom(otherType, METHOD_RESTRICTION) c.isDerivedFrom(otherType, METHOD_UNION) = otherType == a || otherType == b || a.isDerivedFrom(otherType, METHOD_RESTRICTION) || b.isDerivedFrom(otherType, METHOD_RESTRICTION) c.isDerivedFrom(otherType, METHOD_EXTENSION) = false c.isDerivedFrom(otherType, METHOD_LIST) a.isDerivedFrom(otherType, METHOD_LIST) && b.isDerivedFrom(otherType, METHOD_LIST) If <simpleType name="b"> <list base="a"/> </simpleType> b.isDerivedFrom(otherType, METHOD_RESTRICTION) = otherType == xsd:anySimpleType || otherType == xsd:anyType b.isDerivedFrom(otherType, METHOD_UNION) = false b.isDerivedFrom(otherType, METHOD_EXTENSION) = false b.isDerivedFrom(otherType, METHOD_LIST) otherType == a || a.isDerivedFrom(otherType, METHOD_RESTRICTION) If <complexType name="b"> <extension base="a"/> </complexType> b.isDerivedFrom(otherType, METHOD_RESTRICTION) = otherType == xsd:anySimpleType || otherType == xsd:anyType b.isDerivedFrom(otherType, METHOD_UNION) = false b.isDerivedFrom(otherType, METHOD_EXTENSION) = otherType == a || a.isDerivedFrom(otherType, METHOD_EXTENSION) b.isDerivedFrom(otherType, METHOD_LIST) false For two non-zero integers, i and j a.isDerivedFrom(otherType, i | j) a.isDerivedFrom(otherType, i) || a.isDerivedFrom(otherType, j) This algebra should result in the following desirable features: if a.isDerivedFrom(otherType, METHOD_RESTRICTION) then every member of the value set for a is also a member of the value set of otherType. if a.isDerivedFrom(otherType, METHOD_LIST) then every member of the value set for a is a list of members of the value set of otherType. if a.isDerivedFrom(otherType, METHOD_EXTENSION) then every element that is valid for type a is not missing any required content or attributes for otherType.
Received on Friday, 16 January 2004 02:48:31 UTC