[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [wtp-dev] Loading a ContentModel correctly
|
Well, that got me closer, it's at least resolving the internal DTD,
but not loading the external one. The url resoultion still shows up at
file:///staff.dtd.
<?xml version="1.0" encoding="UTF-8"?><?TEST-STYLE PIDATA?>
<!DOCTYPE staff SYSTEM "staff.dtd" [
<!ENTITY ent1 "es">
<!ENTITY ent2 "1900 Dallas Road">
<!ENTITY ent3 "Texas">
<!ENTITY ent4 "<entElement domestic='Yes'>Element
data</entElement><?PItarget PIdata?>">
<!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
<!ENTITY ent1 "This entity should be discarded">
<!NOTATION notation1 PUBLIC "notation1File">
<!NOTATION notation2 SYSTEM "notation2File">
]>
<!-- This is comment number 1.-->
<staff>
<employee>
<employeeId>EMP0001</employeeId>
<name>Margaret Martin</name>
<position>Accountant</position>
<salary>56,000</salary>
<gender>Female</gender>
<address domestic="Yes">1230 North Ave. Dallas, Texas 98551</address>
</employee>
</staff>
With the property enabled, it loads the internal DTD, but the external
DTD is never loaded, the resolution doesn't seem to be happening
correctly for the file path.
Dave
On 08/10/2010 12:54 AM, Jesper Steen Møller wrote:
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
_______________________________________________
wtp-dev mailing list
wtp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/wtp-dev