CHAPTER 3 VALIDATION The attribute mixed is a Boolean, defaulting to false, which specifies whether text is allowed within the content. To this point, the attribute has not appeared on any of the complexType definitions; thus, the elements using the complex data type have allowed only element and/or attributes. The attribute pertains only to the element using the type. It does not affect elements declared within the element s content. For example, the declaration of the meetingNote element is of mixed content, mixed=”true”. The elements declared as child elements, such as meetingdate, base their allowable content on the data type specified in their own declaration. In the case of meetingdate, the type is xsd:date, so text content is allowed. You may also have noticed the use of the xsd:all element. This is an anonymous element group since it is local to the meetingNote definition and has no name. A sequence would not have been a good option to use in this case because the ordering of the meetingdate and meetingtime elements could not be determined ahead of time. It was a better decision to use xsd:all, which enforces that the elements must appear within the note content but in no specified order. Complex Content Complex content allows you to restrict or extend a complex type. You have already seen how restrictions work, so now I will show how to use complexContent to extend a complex type. Suppose you wanted to extend the meetingNote definition in Listing 3-29 and allow an additional element for the location, called meetingLocation. Unfortunately, you can t do this. The base type meetingNote is using xsd:all. This element will not allow you to extend the type and add another element to the mix. You would either have to rewrite the definition and force sequencing or create a new data type. In this case, this is how you would rewrite the definition using sequence: The xsd:all element has been removed and replaced with xsd:sequence. These elements must not show up in the exact order though may be intermixed with text content because of the mixed=”true” attribute. An attribute named enabledhas also been declared as a Boolean with a default value of true. You can now extend this definition:
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services
No comments yet.
Sorry, the comment form is closed at this time.