- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Thu, 23 May 2002 11:34:17 +0100
- To: zze-MARCHEGAY Michael stagiaire FTRD/DTL/LAN <michael.marchegay@rd.francetelecom.com>
- CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi Michaël, > So a complexContent is usefull only when used in a type declaration, > isn't it ? You can only use xs:complexContent within a type definition, so yes. But from your example, it looks like you meant within a *named* type definition as opposed to an anonymous one? > If I use one in a "inline" type definition for an element: > > <xs:element> > <xs:complexType> > <xs:complexContent> > <xs:restriction base="personName"> > <xs:sequence> > <xs:element name="surname"/> > </xs:sequence> > </xs:restriction> > </xs:complexContent> > </xs:complexType> > </xs:element> > > this has **exactly** the same signification as if I write > > <xs:element> > <xs:complexType> > <xs:sequence> > <xs:element name="surname"/> > </xs:sequence> > </xs:complexType> > </xs:element> > > isn't it ? Assuming that the xs:element elements in the above had a name attribute with a value of 'person' (to create a person element)... It depends on what you're using to process the instance document that's been validated against the schema. If you were using XSLT/XPath 2.0 (or XQuery) for example, then in the first case: person instance of element of type personName would be true, because a person element's type would be derived from 'personName', whereas in the second case it would be false because it wasn't. Also if you did a cast like: treat as element of type personName (person) then this would work be OK if you used the first element declaration, but you'd get a static error if you used the second element declaration because it's impossible to cast an element to a type if its type isn't derived from that type. On the other hand, in terms of just running a validator over the instance and getting a yes/no answer about whether the instance is valid according to the schema, then yes, they're exactly the same. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Thursday, 23 May 2002 06:34:20 UTC