| Programmatic use of XMLCorePlugin and ICatalog APIs [message #224338] |
Tue, 25 November 2008 17:07  |
Ray Chapman Messages: 1 Registered: July 2009 |
Junior Member |
|
|
We provide a set of plugins that allow our users to set up a Java EE
project, via a New Project wizard, to model domain specific objects. A
user can then hit a button to generate an XSD from their model. The
project automatically builds following XSD generation. However, errors
are reported by org.eclipse.wst.validation.validationbuilder when
validating the XSD due to a failure to resolve an imported namespace in
the generated XSD.
We understand if we add an entry into Eclipse XML Catalog for the location
of XSD for referenced namespace, validation will succeed. Assuming we
have knowledge of the imported namespace and its XSD location prior to XSD
generation, it seems we could programmatically add an entry to the Eclipse
XML User catalog using something like the following (obtained from
org.eclipse.wst.xsd.validation.tests project in class
org.eclipse.wst.xsd.validation.tests.internal.BugFixesTest):
ICatalog catalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
for (int i = 0; i < nextCatalogs.length; i++)
{
INextCatalog nextCatalog = nextCatalogs[i];
if(XMLCorePlugin.USER_CATALOG_ID.equals(nextCatalog.getId()) )
{
ICatalog userCatalog = nextCatalog.getReferencedCatalog();
if(userCatalog != null)
{
ICatalogEntry catalogEntry =
(ICatalogEntry)userCatalog.createCatalogElement
(ICatalogEntry.ENTRY_TYPE_PUBLIC);
catalogEntry.setKey("testKey");
catalogEntry.setURI("http://testuri");
userCatalog.addCatalogElement(catalogEntry);
}
}
}
The package name for ICatalog is
org.eclipse.wst.xml.core.internal.catalog.provisional.ICatal og. We feel
reluctant to use a provisional package. Can someone from the web tools
team provide some guidance about programmatically modifying the XML
Catalog.
Thanks!
|
|
|