for (final IDocTypeResolutionEntry dialectDocTypeResolutionEntry : dialectDocTypeResolutionEntries) {
boolean addDialectDocTypeResolutionEntry = true;
final DocTypeIdentifier dialectDocTypeResolutionEntryPublicID = dialectDocTypeResolutionEntry.getPublicID();
final DocTypeIdentifier dialectDocTypeResolutionEntrySystemID = dialectDocTypeResolutionEntry.getSystemID();
for (final IDocTypeResolutionEntry docTypeResolutionEntry : docTypeResolutionEntries) {
final DocTypeIdentifier docTypeResolutionEntryPublicID = docTypeResolutionEntry.getPublicID();
final DocTypeIdentifier docTypeResolutionEntrySystemID = docTypeResolutionEntry.getSystemID();
final boolean publicIDMatches;
if (dialectDocTypeResolutionEntryPublicID == null) {
publicIDMatches = (docTypeResolutionEntryPublicID == null);
} else {
publicIDMatches = (docTypeResolutionEntryPublicID != null && docTypeResolutionEntryPublicID.equals(dialectDocTypeResolutionEntryPublicID));
}
final boolean systemIDMatches;
if (dialectDocTypeResolutionEntrySystemID == null) {
systemIDMatches = (docTypeResolutionEntrySystemID == null);
} else {
systemIDMatches = (docTypeResolutionEntrySystemID != null && docTypeResolutionEntrySystemID.equals(dialectDocTypeResolutionEntrySystemID));
}
if (publicIDMatches && systemIDMatches) {
if (!dialectDocTypeResolutionEntry.equals(docTypeResolutionEntry)) {
throw new ConfigurationException(
"Cannot initialize: two dialects provide different (non-equal) " +
"DOCTYPE resolution entries for PUBLICID \"" + docTypeResolutionEntryPublicID +
"\" and SYSTEMID \"" + docTypeResolutionEntrySystemID + "\"");
}
// No need to repeat an entry (even if it is a Set!)
addDialectDocTypeResolutionEntry = false;
}
}
if (addDialectDocTypeResolutionEntry) {
docTypeResolutionEntries.add(dialectDocTypeResolutionEntry);
}
}
/*
* Check that two dialects do not specify conflicting DOCTYPE translations
* for the same PUBLIC and SYSTEM IDs.
*/
final Set<IDocTypeTranslation> dialectDocTypeTranslations = dialect.getDocTypeTranslations();
for (final IDocTypeTranslation dialectDocTypeTranslation : dialectDocTypeTranslations) {
boolean addDialectDocTypeTranslation = true;
final DocTypeIdentifier dialectDocTypeTranslationSourcePublicID = dialectDocTypeTranslation.getSourcePublicID();
final DocTypeIdentifier dialectDocTypeTranslationSourceSystemID = dialectDocTypeTranslation.getSourceSystemID();
final DocTypeIdentifier dialectDocTypeTranslationTargetPublicID = dialectDocTypeTranslation.getTargetPublicID();
final DocTypeIdentifier dialectDocTypeTranslationTargetSystemID = dialectDocTypeTranslation.getTargetSystemID();
for (final IDocTypeTranslation docTypeTranslation : docTypeTranslations) {
final DocTypeIdentifier docTypeTranslationSourcePublicID = docTypeTranslation.getSourcePublicID();
final DocTypeIdentifier docTypeTranslationSourceSystemID = docTypeTranslation.getSourceSystemID();
final DocTypeIdentifier docTypeTranslationTargetPublicID = docTypeTranslation.getTargetPublicID();
final DocTypeIdentifier docTypeTranslationTargetSystemID = docTypeTranslation.getTargetSystemID();
boolean sourcePublicIDMatches = false;
boolean sourceSystemIDMatches = false;
if (dialectDocTypeTranslationSourcePublicID == null) {
sourcePublicIDMatches = (docTypeTranslationSourcePublicID == null);
} else {
sourcePublicIDMatches = (docTypeTranslationSourcePublicID != null && docTypeTranslationSourcePublicID.equals(dialectDocTypeTranslationSourcePublicID));
}
if (dialectDocTypeTranslationSourceSystemID == null) {
sourceSystemIDMatches = (docTypeTranslationSourceSystemID == null);
} else {
sourceSystemIDMatches = (docTypeTranslationSourceSystemID != null && docTypeTranslationSourceSystemID.equals(dialectDocTypeTranslationSourceSystemID));
}
if (sourcePublicIDMatches && sourceSystemIDMatches) {
final boolean targetPublicIDMatches;
if (dialectDocTypeTranslationTargetPublicID == null) {
targetPublicIDMatches = (docTypeTranslationTargetPublicID == null);
} else {
targetPublicIDMatches = (docTypeTranslationTargetPublicID != null && docTypeTranslationTargetPublicID.equals(dialectDocTypeTranslationTargetPublicID));
}
final boolean targetSystemIDMatches;
if (dialectDocTypeTranslationTargetSystemID == null) {
targetSystemIDMatches = (docTypeTranslationTargetSystemID == null);
} else {
targetSystemIDMatches = (docTypeTranslationTargetSystemID != null && docTypeTranslationTargetSystemID.equals(dialectDocTypeTranslationTargetSystemID));
}
if (!targetPublicIDMatches || !targetSystemIDMatches) {
throw new ConfigurationException(
"Cannot initialize: two dialects provide different (non-equal) " +