try
{
for (int i = 0; i < globalRules.length; i++)
{
final DataSchemaRule rule = globalRules[i];
if (rule instanceof GlobalRule)
{
writer.writeTag(ClassicEngineBoot.DATASCHEMA_NAMESPACE, "global-mapping", XmlWriterSupport.OPEN);
writeAttributes(writer, rule.getStaticAttributes());
writer.writeCloseTag();
}
}
for (int i = 0; i < indirectRules.length; i++)
{
final DataSchemaRule rule = indirectRules[i];
if (rule instanceof MetaSelectorRule)
{
final MetaSelectorRule selectorRule = (MetaSelectorRule) rule;
writer.writeTag(ClassicEngineBoot.DATASCHEMA_NAMESPACE, "indirect-mapping", XmlWriterSupport.OPEN);
final MetaSelector[] selectors = selectorRule.getSelectors();
for (int j = 0; j < selectors.length; j++)
{
final MetaSelector selector = selectors[j];
final AttributeList selectorAttributeList = new AttributeList();
selectorAttributeList.setAttribute(ClassicEngineBoot.DATASCHEMA_NAMESPACE, "domain", selector.getDomain());
selectorAttributeList.setAttribute(ClassicEngineBoot.DATASCHEMA_NAMESPACE, "name", selector.getName());
final String stringValue = ConverterRegistry.toAttributeValue(selector.getValue());
selectorAttributeList.setAttribute(ClassicEngineBoot.DATASCHEMA_NAMESPACE, "value", stringValue);
writer.writeTag(ClassicEngineBoot.DATASCHEMA_NAMESPACE, "match", selectorAttributeList,
XmlWriterSupport.CLOSE);
}
writeAttributes(writer, rule.getStaticAttributes());
writer.writeCloseTag();
}
}
for (int i = 0; i < directRules.length; i++)
{
final DataSchemaRule rule = directRules[i];
if (rule instanceof DirectFieldSelectorRule)
{
final DirectFieldSelectorRule fieldSelectorRule = (DirectFieldSelectorRule) rule;
writer.writeTag(ClassicEngineBoot.DATASCHEMA_NAMESPACE,
"direct-mapping", "fieldame", fieldSelectorRule.getFieldName(), XmlWriterSupport.OPEN);
writeAttributes(writer, rule.getStaticAttributes());
writer.writeCloseTag();
}
}
}
catch (BeanException e)