Every element is defined in a corresponding <element> XML element in the schema. Elements can be nested. An element is simply a container for other attributes, or sub-elements. It must have a name and it may serve as a container of default values for collection elements (for example, siteDefaults holds the default values for sites in the <sites> collection).
<ELEMENT>name="" [String, Required] [XML name of the element]
isCollectionDefault="false" [bool] [Indicates if default values are held for other elements in this collection]
/>
Collection Schema
Every collection is defined in a corresponding <collection> XML element in the schema. Collections contain multiple elements, which can be added and removed from it individually. Typically the collection directive names are "add", "remove" and "clear", but some collections use different names for clarity (for example, the collection is using "site" instead of "add"). This is done by specifying values for addElement, removeElement and clearElement in the collection schema. If a collection directive is missing from the schema, the collection will not support it. The collection schema may specify the name of a default element, that will be used as a container of default values for collection elements (this complements isCollectionDefault in the element schema).
For example, the collection is using siteDefaults as the default element. Most collections append elements as they merge configuration files down the namespace, but some may specify mergeAppend="false" in the schema to have a prepend behavior. For example, consider two levels of configuration: applicationHost.config and web.config in a site.
<myCollection>In web.config:
<add value="1"/>
</myCollection>
<myCollection>
<add value="2"/>
</myCollection>
If the collection appends, its merged (effective) configuration at the site level will be:
<myCollection>However, if it prepends, it will be:
<add value="1"/>
<add value="2"/>
</myCollection>
<myCollection>
<add value="2"/>
<add value="1"/>
</myCollection>
Some collections may allow duplicate entries by specifying allowDuplicates="true" in their schema. This is mostly done to support legacy collections in the .NET framework (in machine.config).
Some collections may allow additional attributes in them, beyond those specified in the schema. This is done by specifying allowUnrecognizedAttributes="true" in their schema. It is mostly done to support provider-based collections in the .NET framework.
ليست هناك تعليقات:
إرسال تعليق