XML Tutorial/XML Schema/Annotation — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:26, 26 мая 2010
Annotating Schemas: add information about your schema or its elements.
You can create annotations right after the xsd:schema element to document the entire schema.
<annotation id="ID"
{any attributes with non-schema namespace}>
Content: (appInfo | documentation)*
</annotation>
File: Schema.xsd
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<xsd:annotation>
<xsd:documentation>
test
</xsd:documentation>
</xsd:annotation>
</xsd:schema>
Annotations for element tags
<?xml version = "1.0" ?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation>
Schema for customer name information.
</xs:documentation>
</xs:annotation>
<xs:element name = "Customer">
<xs:annotation>
<xs:documentation>
MiddleInitial is optional
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:group ref = "NameGroup" />
</xs:complexType>
</xs:element>
<xs:group name = "NameGroup">
<xs:sequence>
<xs:element name = "FirstName" type = "xs:string" />
<xs:element name = "MiddleInitial" type = "xs:string" />
<xs:element name = "LastName" type = "xs:string" />
</xs:sequence>
</xs:group>
</xs:schema>
Annotations provides documentation information, as well as additional application information
<annotation id="unique identifier">
The <annotation> declaration can appear as a child of most XML Schema declarations.
The <annotation> declaration adds two forms of information to your declarations:
Application information
Documentation information
Each <annotation> declaration may contain the elements <appinfo> and <documentation>.
These elements may contain any XML content from any namespace.
Each of these elements may also contain a source attribute.
The source attribute is used to refer to an external file that may be used for application information or documentation information.
Annotations usually include <documentation> declarations to describe the features, or uses, of a particular declaration within the XML Schema.