Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » URIResolverExtension / custom Resolvers(Can't seem to get this to ever work.. comparing to XMLCatalogURIResolverExtension)
URIResolverExtension / custom Resolvers [message #729666] Mon, 26 September 2011 18:08 Go to next message
Roger  is currently offline Roger Friend
Messages: 11
Registered: September 2011
Junior Member
So, i'm trying to make my own custom resolver extension class, so I can associate the proper XSD files to XML files based on their location/filename.

Sample code:
@SuppressWarnings("restriction")
public class XSDResolver implements URIResolverExtension {
	
    private static final Log log = LogFactory.getLog(XSDResolver.class);

	@Override
	public String resolve(IFile file, String baseLocation, String publicId, String systemId) {
		
		log.info("File: " + file.getName());
		log.info("Base Location: " + baseLocation);
		log.info("Public ID: " + publicId);
		log.info("System ID: " + systemId);
		XMLCatalogURIResolverExtension e = new XMLCatalogURIResolverExtension();
		String result = e.resolve(file, baseLocation, publicId, systemId);
		log.error("RESULT: " + result);
		if (result != null) {
			return result;
		}
		return null;
	}
	
	private String getXsdFromFileName(String fileName) {
		log.error("**********************");
		return "file:/home/rstudner/svn/studio-trunk/core/studio/templates/knowledgebase.xsd";
	}
	
}


I'd love to know, how to take a given filename, and associate XSD with it.. but so far nothing in these forums/any book/anything on Google is helping me out Smile
Re: URIResolverExtension / custom Resolvers [message #729667 is a reply to message #729666] Mon, 26 September 2011 18:09 Go to previous messageGo to next message
Roger  is currently offline Roger Friend
Messages: 11
Registered: September 2011
Junior Member
And note.. if I dump this resolver, and put the explicit stuff in my xml doc.. then it uses my XML Catalog entry and works hah

So it makes no sense that if I'm simply returning the value from the XML resolver in my own code, why it then fails to work.

thoughts?
Re: URIResolverExtension / custom Resolvers [message #729682 is a reply to message #729667] Mon, 26 September 2011 18:42 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

The resolvers aid in finding associated resources, they don't define that association themselves. For XML validation, you still have to put a reference to the Schema/DTD within the document's text, or be using the org.eclipse.wst.xml.core.externalSchemaLocations extension point.


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: URIResolverExtension / custom Resolvers [message #729982 is a reply to message #729682] Tue, 27 September 2011 12:11 Go to previous messageGo to next message
Roger  is currently offline Roger Friend
Messages: 11
Registered: September 2011
Junior Member
Do you have any example or know where the "doc" is for:

"or be using the org.eclipse.wst.xml.core.externalSchemaLocations extension point."

Hardest thing about doing RCP stuff i've found so far, is there is almost no documentation of anything Smile

Thanks

Roger
Re: URIResolverExtension / custom Resolvers [message #731033 is a reply to message #729982] Thu, 29 September 2011 18:31 Go to previous messageGo to next message
Nick Sandonato is currently offline Nick SandonatoFriend
Messages: 126
Registered: July 2009
Senior Member
Hi Roger,

The only real doc (we really should have more) that exists for the externalSchemaLocations is within the interface for org.eclipse.wst.xml.core.contentmodel.modelquery.IExternalSchemaLocationProvider. Basically, you'll implement this provider so that it can associate schemas based on the URI that it is passed. These providers are invoked in the absence of a referenced schema within the XML. You can find an example provider in the org.eclipse.wst.xml.core.tests ExternalSchemaTest scenario.
Re: URIResolverExtension / custom Resolvers [message #731076 is a reply to message #729982] Thu, 29 September 2011 21:11 Go to previous message
David Carver is currently offline David CarverFriend
Messages: 174
Registered: July 2009
Senior Member
Roger wrote on Tue, 27 September 2011 08:11
Do you have any example or know where the "doc" is for:

"or be using the org.eclipse.wst.xml.core.externalSchemaLocations extension point."

Hardest thing about doing RCP stuff i've found so far, is there is almost no documentation of anything Smile

Thanks

Roger


Here is a code example of how we resolve what XML Schema to use for the XSLT Editor. Depending on the version attribute determines what XML Schema is loaded for the editor, and then loaded into the Content Model.

http://dev.eclipse.org/viewcvs/viewvc.cgi/sourceediting/plugins/org.eclipse.wst.xsl.core/src/org/eclipse/wst/xsl/core/resolver/ResolverExtension.java?view=markup&root=WebTools_Project

Hope that helps.
Previous Topic:Import WSDL and XSD files
Next Topic:Cannot open JSP in Web Page Editor
Goto Forum:
  


Current Time: Wed Apr 24 23:37:03 GMT 2024

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

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

Back to the top