The xs:openContent provides an mechanism for making XSD's extensible.
The xs:openContent node tells the validator the containing element (in the instance document) can contain additional XML elements that are not defined within this schema. Prior to XSD 1.1 the only way to do with was via the xs:any node, however xs:openContent allows a greater level of control and freedom.
The xs:schema element can also have a xs:defaultOpenContent node which works the same as the xs:openContent node, but is applied to all elements defined within the schema.
|If an xs:defaultOpenContent node is defined for a schema then it can be turned off for a given element by declaring an xs:openContent node and setting the mode=none|
|Id||user defined ID to uniquely identify the entity within the schema|
The xs:openContent node can have a child xs:any which defines the rules that additional elements must comply with.
The following XSD code
|XSD Sample Code||Copy Code|
<element name="Book"> <complexType> <openContent mode="interleave"> <any namespace="http://www.book.org" processContents="strict" /> </openContent> <sequence> <element name="Title" type="string" /> <element name="Author" type="string" /> <element name="Date" type="gYear" /> <element name="ISBN" type="string" /> <element name="Publisher" type="string" /> </sequence> </complexType> </element>
Will be represented like this
|Resulting XML Document||Copy Code|
<Book xmlns:bk="http://www.book.org"> <bk:Binding>Hardcover</bk:Binding> <Title>My Life and Times</Title> <bk:Size>5 x 7</bk:Size> <Author>Paul McCartney</Author> <bk:InStock>true</bk:InStock> <Date>1998</Date> <bk:Category>Non-fiction</bk:Category> <ISBN>1-56592-235-2</ISBN> <bk:NumPages>299</bk:NumPages> <Publisher>McMillin Publishing</Publisher> <bk:AvailableOnTape>false</bk:AvailableOnTape> </Book>
Properties that apply to a type are shown inline at the bottom of the items container.
Values that are inherited from the base types are shown in brackets, values specifically set against the item are shown without brackets.
If a facet is not valid for a given type (typically because of its data type), then its value is shown in red.
|Inline properties can be disabled in the Options.|