private static IDocument createDocumentWithDTD(
     final DocumentType documentType, final String rootElementName) {
   final IDocument result = new Document(new QualifiedName(null, rootElementName));
   result.setPublicID(documentType.getPublicId());
   result.setSystemID(documentType.getSystemId());
   return result;
 }
  @Test
  public void testPluginNamespaceDefinition() throws Exception {
    final ConfigurationRegistry configurationRegistry =
        new ConfigurationRegistryImpl(new ConfigLoaderJob());
    configurationRegistry.loadConfigurations();

    final DocumentType doctype =
        configurationRegistry.getDocumentType("http://org.eclipse.vex/namespace", null);
    assertNotNull(doctype);
    assertEquals("test schema doctype", doctype.getName());
  }
  @Test
  public void testPluginDoctypeDefinition() throws Exception {
    final ConfigurationRegistry configurationRegistry =
        new ConfigurationRegistryImpl(new ConfigLoaderJob());
    configurationRegistry.loadConfigurations();

    final DocumentType doctype =
        configurationRegistry.getDocumentType("-//Vex//DTD Test//EN", null);
    assertNotNull(doctype);
    assertEquals("test.dtd", doctype.getSystemId());
  }
  @Test
  public void testGetDocumentTypesWithStyles() throws Exception {
    final ConfigurationRegistry configurationRegistry =
        new ConfigurationRegistryImpl(new ConfigLoaderJob());
    configurationRegistry.loadConfigurations();

    final DocumentType[] doctypes = configurationRegistry.getDocumentTypesWithStyles();
    boolean dtdFound = false;
    boolean schemaFound = false;
    for (final DocumentType doctype : doctypes) {
      if ("test doctype".equals(doctype.getName())) {
        dtdFound = true;
      }
      if ("test schema doctype".equals(doctype.getName())) {
        schemaFound = true;
      }
    }
    assertTrue("DoctypeWithStyles should return Doctype with DTD ", dtdFound);
    assertTrue("DoctypeWithStyles should return Docype with namespace ", schemaFound);
  }
  private static IDocument createDocumentWithSchema(
      final DocumentType documentType, final String rootElementName) {
    final String defaultNamespaceUri = documentType.getNamespaceName();
    final Document document = new Document(new QualifiedName(defaultNamespaceUri, rootElementName));

    final IElement root = document.getRootElement();
    root.declareDefaultNamespace(defaultNamespaceUri);

    final WTPVEXValidator validator =
        new WTPVEXValidator(new DocumentContentModel(null, null, null, root));
    int namespaceIndex = 1;
    for (final String namespaceUri : validator.getRequiredNamespaces()) {
      if (!defaultNamespaceUri.equals(namespaceUri)) {
        root.declareNamespace("ns" + namespaceIndex++, namespaceUri);
      }
    }

    return document;
  }
 private static boolean isDTD(final DocumentType documentType) {
   final String systemId = documentType.getSystemId();
   return systemId != null && systemId.toLowerCase().endsWith(".dtd");
 }