[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [wtp-dev] Loading a ContentModel correctly

Hi Dave

I've been using
org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager.getCMDocument(String,
String, String), but first you need to set the properties
PROPERTY_AUTO_LOAD = true and PROPERTY_ASYNC_LOAD = false on the
CMDocumentManager.

-Jesper

On Tue, Aug 10, 2010 at 6:28 AM, David Carver <d_a_carver@xxxxxxxxx> wrote:
>  I have some unit tests in which I need to load up a content model, the xml
> file references a DTD, with a SYSTEMID = "staff.dtd".  Unfortunately, the
> code in this message always resolves this is:
>
> file:///staff.dtd
>
> Instead of trying to resolve it relative to the XML file that is referencing
> it.
>
> I've tried putting these entries into a XML Catalog entry, as when I do a
>   URIResolver uriResolver = ModelQueryUtil.getIdResolver(doc);, it returns
> the XMLCatalogResolver class.
>
> When I check the CMDocument, there are is nothing in there, and it acts as
> if the DTD is never actually loaded or walked to create the content model.
>
> There are several W3C unit tests that need to have a content model to go
> with them, but so far the code below doesn't seem to work for correctly
> loading and generating the content model.
>
> Valentine or Nitin any idea what I may be doing wrong?
>
> Dave
>
>
> public Document load(java.net.URL url) throws DOMTestLoadException {
>    IStructuredDocument document = null;
>    Document doc = null;
>    IDOMModel model = null;
>
>
>    try {
>
>        model = (IDOMModel)
> StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
>
>        FileInputStream file = new FileInputStream(url.getPath());
>        InputStream inputStream = Utilities.getMarkSupportedStream(file);
>        ModelHandlerForXML xmlModelHandler = new ModelHandlerForXML();
>        IModelLoader xmlModelLoader = xmlModelHandler.getModelLoader();
>        xmlModelLoader.load(inputStream, model, null);
>
>    }
>    catch (IOException e) {
>        e.printStackTrace();
>    } catch (Exception e) {
>        e.printStackTrace();
>    }
>
>    IDOMModel docModel = (IDOMModel)model;
>    doc = (Document)docModel.getDocument();
>
>    // Load up a ContentModel if possible
>    ModelQuery modelQuery = ModelQueryUtil.getModelQuery(doc);
>    if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null))
> {
>        CMDocumentLoader loader = new CMDocumentLoader(doc, modelQuery);
>        loader.loadCMDocuments();
>    }
>
>    URIResolver uriResolver = ModelQueryUtil.getIdResolver(doc);
> _______________________________________________
> wtp-dev mailing list
> wtp-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/wtp-dev
>