* the schema
* @throws XMLSchemaFileImportException
*/
private static void readMatchingRule( Element element, Schema schema ) throws XMLSchemaFileImportException
{
MutableMatchingRule mr = null;
// OID
Attribute oidAttribute = element.attribute( OID_TAG );
if ( ( oidAttribute != null ) && ( !oidAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
{
mr = new MutableMatchingRule( oidAttribute.getValue() );
}
else
{
throw new XMLSchemaFileImportException( Messages.getString( "XMLSchemaFileImporter.NoMatchingRuleForOID" ) ); //$NON-NLS-1$
}
// Schema
mr.setSchemaName( schema.getSchemaName() );
// Aliases
Element aliasesElement = element.element( ALIASES_TAG );
if ( aliasesElement != null )
{
List<String> aliases = new ArrayList<String>();
for ( Iterator<?> i = aliasesElement.elementIterator( ALIAS_TAG ); i.hasNext(); )
{
Element aliasElement = ( Element ) i.next();
aliases.add( aliasElement.getText() );
}
if ( aliases.size() >= 1 )
{
mr.setNames( aliases.toArray( new String[0] ) );
}
}
// Description
Element descriptionElement = element.element( DESCRIPTION_TAG );
if ( ( descriptionElement != null ) && ( !descriptionElement.getText().equals( "" ) ) ) //$NON-NLS-1$
{
mr.setDescription( descriptionElement.getText() );
}
// Obsolete
Attribute obsoleteAttribute = element.attribute( OBSOLETE_TAG );
if ( ( obsoleteAttribute != null ) && ( !obsoleteAttribute.getValue().equals( "" ) ) ) //$NON-NLS-1$
{
mr.setObsolete( readBoolean( obsoleteAttribute.getValue() ) );
}
// Syntax OID
Element syntaxOidElement = element.element( SYNTAX_OID_TAG );
if ( ( syntaxOidElement != null ) && ( !syntaxOidElement.getText().equals( "" ) ) ) //$NON-NLS-1$
{
mr.setSyntaxOid( syntaxOidElement.getText() );
}
// Adding the matching rule to the schema
schema.addMatchingRule( mr );
}