XML Tutorial/XML Schema/Annotation

Материал из Web эксперт
Версия от 11:26, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Annotating Schemas: add information about your schema or its elements.

   <source lang="xml">

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)*


File: Schema.xsd <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">



Annotations for element tags

   <source lang="xml">

<?xml version = "1.0" ?> <xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">

        Schema for customer name information.
  <xs:element name = "Customer">
            MiddleInitial is optional 
        <xs:group ref = "NameGroup" />
  <xs:group name = "NameGroup">
        <xs:element name = "FirstName" type = "xs:string" />
        <xs:element name = "MiddleInitial" type = "xs:string" />
        <xs:element name = "LastName" type = "xs:string" />


Annotations provides documentation information, as well as additional application information

   <source lang="xml">

<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.</source>