Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » How to get the xmlcatalog entries from the eclipse preference
How to get the xmlcatalog entries from the eclipse preference [message #205810] Fri, 14 December 2007 06:55 Go to next message
Debasis Mishra is currently offline Debasis MishraFriend
Messages: 36
Registered: July 2009
Member
Hi all,
I want to get the xmlcatalog entries(Mean to get the the URL of the
schema defined in the eclipreference/xml catalog) in Java.

Can I get some idea how to get it.


Thanks in advance
Debasis Mishra
Re: How to get the xmlcatalog entries from the eclipse preference [message #205908 is a reply to message #205810] Sat, 15 December 2007 18:52 Go to previous messageGo to next message
Lawrence Mandel is currently offline Lawrence MandelFriend
Messages: 486
Registered: July 2009
Senior Member
Hi Debasis,

To get the URL of a schema defined in the XML catalog you should query
with the URI resolution framework. (The XML catalog is a URI resolver
plugged into that framework.)

Add the following dependency to your plug-in:
org.eclipse.wst.common.uriresolver

Then query as follows:

URIResolver resolver = URIResolverPlugin.createResolver();
String logicalResult = resolver.resolve("", SCHEMA_NAMESPACE,
SCHEMA_SYSTEMID_IF_KNOWN);
String physicalResult = resolver.resolvePhysicalLocation("",
SCHEMA_NAMESPACE, logicalResult);

The physicalResult is the URL of the schema.

Note that using this approach you will query all URI resolvers registered
with WTP. Out of the box WTP includes 3 resolvers: the XML catalog,
Internet cache, and component resolver. For your purpose the component
resolver likely won't return a result. If the result is not found in the
XML catalog the Internet cache will be consulted.

Lawrence

>Hi all,
> I want to get the xmlcatalog entries(Mean to get the the URL of the
>schema defined in the eclipreference/xml catalog) in Java.
>
>Can I get some idea how to get it.
>>
>Thanks in advance
>Debasis Mishra
Re: How to get the xmlcatalog entries from the eclipse preference [message #205992 is a reply to message #205810] Tue, 18 December 2007 00:07 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2330
Registered: July 2009
Senior Member
Debasis wrote:
> I want to get the xmlcatalog entries(Mean to get the the URL of the
> schema defined in the eclipreference/xml catalog) in Java.
>
> Can I get some idea how to get it.

You'll want to do this:

List entries = new ArrayList();
ICatalog defaultCatalog =
XMLCorePlugin.getDefault().getDefaultXMLCatalog();
if (defaultCatalog != null) {
// Process default catalog
ICatalogEntry[] defaults = defaultCatalog.getCatalogEntries();
for (int entry = 0; entry < defaults.length; entry++) {
entries.add(defaults[entry]);
}
// Process declared OASIS nextCatalogs catalog
INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
for (int nextCatalog = 0; nextCatalog < nextCatalogs.length;
nextCatalog++) {
ICatalog catalog = nextCatalogs[nextCatalog].getReferencedCatalog();
ICatalogEntry[] entries3 = catalog.getCatalogEntries();
for (int entry = 0; entry < nextEntries.length; entry++) {
entries.add(nextEntries[entry]);
}
}
}

Be aware, however, that the catalog support classes are all internal
and subject to change.

---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: How to get the xmlcatalog entries from the eclipse preference [message #207266 is a reply to message #205992] Mon, 21 January 2008 12:48 Go to previous message
Debasis Mishra is currently offline Debasis MishraFriend
Messages: 36
Registered: July 2009
Member
Hello Nitin,
Thanks a lot.sorry for the late reply bcoz I was on leave.
Now I am able to get the schema url specified in the xml catalog.

But what if I'll add the schema url in the userspecified entries not
through
plugin.xml by adding the extension-
"org.eclipse.wst.xml.core.catalogContributions"

will this code work for adding the schema url dynamically in the
userspecied entries in runtime.

I tried with this code but it didn't work.could u plz help me if i am
missing something.


Thanks in advance,
Debasis
Previous Topic:Customizing the Palette of the Web Page editor
Next Topic:Spaces in Foldernames
Goto Forum:
  


Current Time: Fri Nov 21 19:12:32 GMT 2014

Powered by FUDForum. Page generated in 0.02288 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software