| ILOG JRules User Guide > Integrating Application Data > Reference > Mapping Between XML Schema and Dynamic Classes > Schema Types > List and Union Types |
List and Union Types |
PREVIOUS NEXT |
This example demonstrates the use of list and union types in a schema and an XML document. The rules displayExtendedIntMeasure and displayStandardInt are used to test the MeasureSet objects.
Here is the schema:
<simpleType ExtendedInt> <union memberTypes="int string"/> </simpleType> <simpleType IntMeasures> <list itemType="ExtendedInt"/> </simpleType> <element name="measureSet" > <complexType> <sequence> <element name="intMeasures" type="IntMeasures" /> <element name="extendedInt" type="ExtendedInt" /> </sequence> </complexType> </element>
Here is the excerpt from an XML document:
<measureSet> <intMeasures>1 2 3 4 ten 5 unknown</intMeasures> <extendedInt>3</extendedInt> </measureSet>
Here is the XOM representation:
class MeasureSet extends IlrXmlObject
{
Vector intMeasures; // list of (Integer| String) instances
Object extendedInt; // either Integer or String instances
...
}
And here are the rules:
rule displayExtendedIntMeasure
{
when {
ms: MeasureSet ();
m: String () in ms.intMeasures;
}
then {
out.println ( m + " is an extended int.");
}
}
rule displayStandardInt
{
when {
ms: MeasureSet ();
m: Integer () from ms.extendedInt;
}
then {
out.println ( m + " is a standard int.");
}
}
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |