Skip to main content

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

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:


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?


public Document load( 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) {
    } catch (Exception e) {

    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);

    URIResolver uriResolver = ModelQueryUtil.getIdResolver(doc);

Back to the top