ILOG JRules User Guide > Integrating Application Data > Reference > Mapping Between XML Schema and Dynamic Classes > Schema Related Mark-up in XML Documents

The schema-related mark-up in XML documents includes the following elements:

xsi:nil

When an XML element is set to xsi:nil in the XML document instance, its related dynamic class field is set to null. The "isunknown" operator applied on this field returns true. In other words, when an XML object is serialized via the driver.writeObject method, the following information is added to this object:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

The following example demonstrates the mapping of xsi:nil in an XML document. The rule detectPersonWithMissingAddress uses the isunknown keyword to find a person whose address is not known. Note that:

Here is the schema:

<element name="person">
  <complexType>
    <sequence>
     <element name="surname"/>
     <element name="address" nillable="true"/>
   </sequence>
  <complexType>
</element>

Here is the excerpt from an XML document:

<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <surname>Smith</surname>
  <address xsi:nil="true"/>
</person>

And here is the rule:

rule detectPersonWithMissingAddress
{
  when {
    Person ( address isunknown );
  }
  then {
   ...
  }
}

XML namespaces are designed to provide universally unique names for elements and attributes. They enable developers to:

xsi:type

To refine the type of an element in the XML document, you can use xsi polymorphism. This feature substitutes a subtype for the standard type of the element.

The following example demonstrates how this polymorphism can be used. The example uses a schema and an excerpt from an XML document.

Here is the schema:

<element name="person" type="person"/>
  <complexType name=" person " >
    <sequence>
      <element name="name">
      <element name="surname">
    </sequence>
  </complexType>
  <complexType name=" inhabitant ">
    <complexContent>
     <extension base="person">
      <sequence>
        <element name="address"/>
      </sequence>
     </extension>
  </complexType>

And here is an excerpt from an XML document:

<person xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xsi:type="inhabitant">
  <name>John</name>
  <surname>Smith</surname>
  <address>123 Downing Street, London</address>
</person>

xsi:schemaLocation and xsi:noNamespaceSchemaLocation

These functions are supported by the parser. However, this information is not used in the XML binding.

Related Reference

Mapping Between XML Schema and Dynamic Classes
Schema Types
XML Declarations
Schema Mapping Limitations