Search in sources :

Example 1 with XMLAssociationProvider

use of org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.XMLAssociationProvider in project webtools.sourceediting by eclipse.

the class CMVisitorTest method test.

protected void test(String fileName) {
    ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        XMLAssociationProvider provider = new XMLAssociationProvider(new CMDocumentCache()) {
        };
        ModelQuery mq = new ModelQueryImpl(provider);
        Thread.currentThread().setContextClassLoader(CMVisitorTest.class.getClassLoader());
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document document = builder.parse(fileName);
        /*
			 * ClassLoader prevClassLoader =
			 * Thread.currentThread().getContextClassLoader();
			 * Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
			 * Class theClass =
			 * Class.forName("org.apache.xerces.parsers.DOMParser"); DOMParser
			 * parser = (DOMParser)theClass.newInstance();
			 * Thread.currentThread().setContextClassLoader(prevClassLoader);
			 * parser.parse(new InputSource(fileName)); Document document =
			 * parser.getDocument();
			 */
        visitNode(document, mq, 0);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        Thread.currentThread().setContextClassLoader(originalClassLoader);
    }
}
Also used : ModelQueryImpl(org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.ModelQueryImpl) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ModelQuery(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery) XMLAssociationProvider(org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.XMLAssociationProvider) Document(org.w3c.dom.Document) CMDocumentCache(org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache)

Aggregations

DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)1 ModelQueryImpl (org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.ModelQueryImpl)1 XMLAssociationProvider (org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.XMLAssociationProvider)1 CMDocumentCache (org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache)1 Document (org.w3c.dom.Document)1