Search in sources :

Example 1 with DTDUtil

use of org.eclipse.wst.dtd.core.internal.emf.util.DTDUtil in project webtools.sourceediting by eclipse.

the class DTDImpl method buildDTDModel.

public static DTDFile buildDTDModel(String uri) {
    DTDUtil dtdUtil = new DTDUtil();
    dtdUtil.setexpandEntityReferences(true);
    dtdUtil.parse(new ResourceSetImpl(), uri);
    return dtdUtil.getDTDFile();
}
Also used : DTDUtil(org.eclipse.wst.dtd.core.internal.emf.util.DTDUtil) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)

Example 2 with DTDUtil

use of org.eclipse.wst.dtd.core.internal.emf.util.DTDUtil in project webtools.sourceediting by eclipse.

the class DTDParserTest method testMultipleCommentParsing.

public void testMultipleCommentParsing() throws IOException {
    DTDUtil util = new DTDUtil();
    String sampleDTDpath = "/resources/dtdParserTest/sample.dtd";
    URL bundleURL = DTDCoreTestsPlugin.getDefault().getBundle().getEntry(sampleDTDpath);
    assertNotNull(sampleDTDpath + " not found in bundle", bundleURL);
    // Do not rely on Common URI Resolver to find the contents
    URL fileURL = FileLocator.toFileURL(bundleURL);
    util.parse(fileURL.toExternalForm());
    DTDFile dtdFile = util.getDTDFile();
    assertEquals(UNEXPECTED_FILE_CONTENTS, 1, dtdFile.getDTDContent().size());
    Object object = dtdFile.getDTDContent().get(0);
    assertTrue(UNEXPECTED_FILE_CONTENTS, object instanceof DTDElement);
    DTDElement dtdElement = (DTDElement) object;
    String comment = dtdElement.getComment();
    assertEquals("Comment value was not as expected", " line one \n line two ", comment);
}
Also used : DTDUtil(org.eclipse.wst.dtd.core.internal.emf.util.DTDUtil) DTDElement(org.eclipse.wst.dtd.core.internal.emf.DTDElement) URL(java.net.URL) DTDFile(org.eclipse.wst.dtd.core.internal.emf.DTDFile)

Aggregations

DTDUtil (org.eclipse.wst.dtd.core.internal.emf.util.DTDUtil)2 URL (java.net.URL)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 DTDElement (org.eclipse.wst.dtd.core.internal.emf.DTDElement)1 DTDFile (org.eclipse.wst.dtd.core.internal.emf.DTDFile)1