Programmatic use of XMLCorePlugin and ICatalog APIs [message #224338] |
Tue, 25 November 2008 17:07  |
Eclipse User |
|
|
|
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!
|
|
|
|
Re: Programmatic use of XMLCorePlugin and ICatalog APIs [message #224447 is a reply to message #224355] |
Wed, 26 November 2008 10:24  |
Eclipse User |
|
|
|
Originally posted by: valentinbaciu.hotmail.com
There are already enhancement requests opened asking for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=135079
https://bugs.eclipse.org/bugs/show_bug.cgi?id=88015
We may have to investigate the impact of supporting newer versions of the
XML Catalog specification before making the API public:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=112284
Moving from provisional to API is not in the plan for WTP 3.1 but as Dave
said the API is fairly stable and we don't break things lightly, even if
internal.
Regards, Valentin
"David Carver" <dcarver@starstandard.org> wrote in message
news:492C7EE8.50409@starstandard.org...
> Ray Chapman wrote:
>> 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.
>
> You can open a bug request to move it from provisional to API. It's been
> provisional for several releases and is pretty stable.
>
> Dave
|
|
|
Powered by
FUDForum. Page generated in 0.06536 seconds