Schema-Related Attributes in XML Documents

The following topics are discussed in this document:


xsi:type

Tamino fully supports the xsi:type attribute. The xsi:type attribute indicates that within an instance a type other than the element's default type as specified in the schema is to be used for validation.

Assume the following schema:

<xs:element name="bill" type="bill"/>
<xs:complexType name="bill" abstract="true">
  <xs:simpleContent>
    <xs:extension base="xs:integer"/>
  </xs:simpleContent>
</xs:complexType>
<xs:complexType name="USDollar">
  <xs:simpleContent>
    <xs:restriction base="bill">
      <xs:enumeration value="1"/>
      <xs:enumeration value="5"/>
      <xs:enumeration value="10"/>
    </xs:restriction>
  </xs:simpleContent>
</xs:complexType>
<xs:complexType name="Euro">
  <xs:simpleContent>
    <xs:restriction base="bill">
      <xs:enumeration value="5"/>
      <xs:enumeration value="10"/>
      <xs:enumeration value="20"/>
    </xs:restriction>
  </xs:simpleContent>
</xs:complexType>
<xs:complexType name="Rupee">
  <xs:simpleContent>
    <xs:restriction base="bill">
      <xs:enumeration value="100"/>
      <xs:enumeration value="200"/>
      <xs:enumeration value="500"/>
    </xs:restriction>
  </xs:simpleContent>
</xs:complexType>

Then the following documents are valid:

<bill xsi:type="USDollar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  10
</bill>
<bill xsi:type="Rupee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  100
</bill>

but this document is invalid:

<bill xsi:type="Euro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  25
</bill>

Usage of the xsi:type attribute is similar to the usage of substitution groups: the referenced type must be derived from the default type as of the schema. In our example, the default type bill is abstract. Hence it must not be used in an XML document and usage of xsi:type is even enforced.

xsi:type was partially supported in Tamino version 4.2, i.e. it validated against the referenced type, but did not check the type hierarchy. Usage of xsi:type was only allowed if the server parameter reject xsi:type was set to "no". This parameter has now been dropped, and xsi:type is fully supported.

xsi:nil

Nillable elements in Tamino correspond to NULL values in SQL. The following example illustrates how an element may be declared in the schema as nillable:

<xs:element name="person">                                           
  <xs:complexType>                                                   
    <xs:sequence>                                                    
      <xs:element name="firstname" type="xs:string"/>                
      <xs:element name="lastname" type="xs:string"/>                 
      <xs:element name="dateOfBirth" type="xs:date" nillable="true"/>
    </xs:sequence>                                                   
  </xs:complexType>                                                  
</xs:element>                                                        

The following document is valid against the schema:

<person>                                                                             
  <firstname>Big</firstname>                                                         
  <lastname>Unknown</lastname>                                                       
  <dateOfBirth xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</person>                                                                            

It indicates that the value of the <dateOfBirth> element is unknown.

In addition to supporting bare validation as described by the XML Schema recommendation, Tamino supports nillable elements in XNode mapping for Adabas and SQL:

  • When mapping an element with nillable="true" to an Adabas field or SQL column, Tamino checks that the NC option is set (Adabas) or that the column does not have the NOT NULL property (SQL);

  • xsi:nil="true" is mapped to the DBMS-specific NULL-indicator and vice versa.

xsi:schemaLocation

This attribute is ignored by Tamino, since Tamino has its own mechanism for determining the schema document to be used for validation.

xsi:noNamespaceSchemaLocation

This attribute is ignored by Tamino.