DB2 Version 9.7 for Linux, UNIX, and Windows

XML decomposition annotations - Specification and scope

Annotations for decomposition can be specified as either element or attribute declarations in an XML schema document.

Annotations can be specified as either:

Annotations as attributes

Annotations specified as simple attributes on element or attribute declarations apply only to that element or attribute on which it is specified.

For example, the db2-xdb:rowSet and db2-xdb:column decomposition annotations can be specified as attributes. These annotations would be specified as follows:
<xs:element name="isbn" type="xs:string"
               db2-xdb:rowSet="TEXTBOOKS" db2-xdb:column="ISBN"/>

The db2-xdb:rowSet and db2-xdb:column annotations apply only to this element named isbn.

Annotations as structured child elements

Annotations specified as structured children elements of an element or attribute declaration must be specified in the schema document within the <xs:annotation><xs:appinfo></xs:appinfo></xs:annotation> hierarchy defined by XML Schema.

For example, the db2-xdb:rowSet and db2-xdb:column annotations can be specified as children elements (they are children of the <db2-xdb:rowSetMapping> annotation) as follows:
<xs:element name="isbn" type="xs:string">
  <xs:annotation>
    <xs:appinfo>
      <db2-xdb:rowSetMapping>
        <db2-xdb:rowSet>TEXTBOOKS</db2-xdb:rowSet>
        <db2-xdb:column>ISBN</db2-xdb:column>
      </db2-xdb:rowSetMapping>
    </xs:appinfo>
  </xs:annotation>
</xs:element>

Specifying the db2-xdb:rowSet and db2-xdb:column annotations as children elements is equivalent to specifying these annotations as attributes (which was shown previously). While more verbose than the method of specifying annotations as attributes, specifying annotations as children elements is required when you need to specify more than one <db2-xdb:rowSetMapping> for an element or attribute; that is, when you need to specify multiple mappings on the same element or attribute declaration.

Global annotations

When an annotation is specified as a child of the <xs:schema> element, it is a global annotation that applies to all of the XML schema documents that make up the XML schema.

For example, the <db2-xdb:defaultSQLSchema> annotation indicates the default SQL schema for all unqualified tables referenced in the XML schema. <db2-xdb:defaultSQLSchema> must be specified as a child element of <xs:schema>:
<xs:schema>
  <xs:annotation>
    <xs:appinfo>
      <db2-xdb:defaultSQLSchema>admin</db2-xdb:defaultSQLSchema>
    </xs:appinfo>
  </xs:annotation>
  …
</xs:schema>

This declaration specifies that all unqualified tables across all schema documents that form this XML schema will have the SQL schema of "admin".

Refer to the documentation for a specific annotation to determine how a particular annotation can be specified.