if (keywordCont.getKeyword() == null) {
System.out.println("Keyword " + keywordName
+ " not found in property "
+ property.getName());
} else {
KeywordReference reference
= definitionsFactory.createKeywordReference();
reference.setKeyword(keywordCont.getKeyword());
container.addValue(reference);
}
} else {
System.out.println(
"Property has no type: could not find keywords");
}
} else if (name.equals("themeDefinition")) {
// Process all the children.
processThemePropertyChildren(element);
} else if (name.equals("choiceType")) {
ChoiceType choiceType = definitionsFactory.createChoiceType();
TypeList typeList = new TypeList();
pushObject(choiceType);
pushObject(typeList);
processThemePropertyChildren(element);
popObject();
popObject();
Iterator it = typeList.getList().iterator();
while (it.hasNext()) {
choiceType.addType((Type) it.next());
}
storeType(choiceType);
} else if (name.equals("pairType")) {
PairType pairType = definitionsFactory.createPairType();
pushObject(pairType);
processThemePropertyChildren(element);
popObject();
storeType(pairType);
} else if (name.equals("fractionType")) {
FractionType fractionType = definitionsFactory.createFractionType();
pushObject(fractionType);
processThemePropertyChildren(element);
popObject();
storeType(fractionType);
} else if (name.equals("first")) {
TypeList typeList = new TypeList();
NameHolder nameHolder = new NameHolder();
pushObject(typeList);
pushObject(nameHolder);
processThemePropertyChildren(element);
popObject();
popObject();
if (!typeList.getList().isEmpty()) {
PairType pair = (PairType) findObject(PairType.class);
pair.setFirst((Type) typeList.getList().get(0));
}
} else if (name.equals("second")) {
TypeList typeList = new TypeList();
NameHolder nameHolder = new NameHolder();
pushObject(typeList);
pushObject(nameHolder);
processThemePropertyChildren(element);
popObject();
popObject();
if (!typeList.getList().isEmpty()) {
PairType pair = (PairType) findObject(PairType.class);
pair.setSecond((Type) typeList.getList().get(0));
}
} else if (name.equals("numerator")) {
TypeList typeList = new TypeList();
NameHolder nameHolder = new NameHolder();
pushObject(typeList);
pushObject(nameHolder);
processThemePropertyChildren(element);
popObject();
popObject();
if (!typeList.getList().isEmpty()) {
FractionType fraction = (FractionType) findObject(FractionType.class);
fraction.setNumerator((Type) typeList.getList().get(0));
}
} else if (name.equals("denominator")) {
TypeList typeList = new TypeList();
NameHolder nameHolder = new NameHolder();
pushObject(typeList);
pushObject(nameHolder);
processThemePropertyChildren(element);
popObject();
popObject();
if (!typeList.getList().isEmpty()) {
FractionType fraction = (FractionType) findObject(FractionType.class);
fraction.setDenominator((Type) typeList.getList().get(0));
}
}else if (name.equals("type")) {
// Process the children in order to find the keyword definitions.
processThemePropertyChildren(element);
} else if (name.equals("typeRef")) {
TypeRef typeRef = definitionsFactory.createTypeRef();
typeRef.setReference(element.getText());
Property property = (Property) findObject(Property.class);
property.setType(typeRef);
} else if (name.equals("keywords")) {
Keywords keywords = definitionsFactory.createKeywords();
pushObject(keywords);
processThemePropertyChildren(element);
popObject();
storeType(keywords);
} else if (name.equals("keyword")) {
// Define a new keyword and add it into the containing set.
Keyword keyword = definitionsFactory.createKeyword();
pushObject(keyword);
processThemePropertyChildren(element);
popObject();
Keywords keywords = (Keywords) findObject(Keywords.class);
keywords.addKeyword(keyword);
} else if (name.equals("inherited")) {
Property prop = (Property) findObject(Property.class);
prop.setInherited(
Boolean.valueOf(element.getText()).booleanValue());
// These are named elements that we are deliberately ignoring for
// the time being.
} else if (name.equals("element") ||
name.equals("media") ||
name.equals("specifications") ||
name.equals("integerType") ||
name.equals("colorType") ||
name.equals("percentageType") ||
name.equals("lengthType") ||
name.equals("uriType") ||
name.equals("mcsComponentURIType") ||
name.equals("appliesTo") ||
name.equals("percentages") ||
name.equals("stringType") ||
name.equals("dependentType") ||
name.equals("angleType") ||
name.equals("functionType") ||
name.equals("timeType") ||
name.equals("numberType") ||
name.equals("fractionType") ||
name.equals("frequencyType") ||
name.equals("emptyList") ||
// From discussion with Paul Duffin, unorderedSetType is being
// phased out, and can be safely ignored since it is only used
// in one case, and there the initialValue falls outside the
// unorderedSetType.
name.equals("unorderedSetType") ||
// Dependent values - such as color, text alignment etc. -
// depend on some value outside of the scope of the property
// definitions (such as the user agent or the writing
// direction). A generic 'initial value' can not be
// calculated for them.
name.equals("dependentValue")) {
// These are types which contain a single other type - lists and
// ordered sets. Rather than creating a simple type that can contain
// another type, they can be ignored, allowing the type tree to be
// navigated without adding an additional (non-functional) layer.
} else if (name.equals("listType") ||
name.equals("orderedSetType")) {
processThemePropertyChildren(element);
} else if (name.equals("propertyRef")) {
// This only works inside initialValue.
PropertyReference reference = (PropertyReference)
findObject(PropertyReference.class);
String propertyName = element.getText();
if (reference == null) {
System.out.println("Ignoring reference to property '" +
propertyName + "'");
} else {
reference.setPropertyName(propertyName);
}
} else if (name.equals("computedRef")) {
// This only works inside initialValue.
ComputedReference reference = (ComputedReference)
findObject(ComputedReference.class);
if (reference == null) {
System.out.println("Ignoring reference to computedRef");
} else {
Named propertyName = definitionsFactory.createProperty();
pushObject(propertyName);
Rules rules = definitionsFactory.createRules();
pushObject(rules);
processThemePropertyChildren(element);
popObject();
popObject();
reference.setPropertyName(propertyName.getName());
reference.setRules(rules.getRuleSet());
}
} else if (name.equals("rule")) {
Rules ruleSet = (Rules) findObject(Rules.class);