Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » XML schema association
XML schema association [message #231872] Tue, 26 May 2009 15:13 Go to next message
Eclipse UserFriend
Originally posted by: mike.xmos.com

Hi,

Is it possible to associate an editor with a XML schema, so that XML
files opened in the editor don't have to reference the schema at the
top? I have got XML content assist working but only if my XML files
include e.g.

<purchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.mysite.com/schema/myschema">

which is a bit verbose...

Mike
Re: XML schema association [message #231887 is a reply to message #231872] Tue, 26 May 2009 17:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

If you have a namespace, setup an XML Catalog entry for your schemas.
It really is recommended that your Schemas have namespaces, otherwise
you may have to write a Custom Resolver that resolves your schema when
the particular XML is loaded.

Dave

Mike Wrighton wrote:
> Hi,
>
> Is it possible to associate an editor with a XML schema, so that XML
> files opened in the editor don't have to reference the schema at the
> top? I have got XML content assist working but only if my XML files
> include e.g.
>
> <purchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="http://www.mysite.com/schema/myschema">
>
> which is a bit verbose...
>
> Mike
Re: XML schema association [message #232015 is a reply to message #231887] Sun, 31 May 2009 22:12 Go to previous messageGo to next message
Jawher Moussa is currently offline Jawher MoussaFriend
Messages: 10
Registered: July 2009
Junior Member
Hi,
Sorry for hijacking this post, but I'm in the same situation : I want to
use the SSE XML editor to edit an xml file which must obeys an xsd schema
but without namespaces (no target namespace in the xsd, and no xmlns in
the xml).
Could David or somebody else give some hints on how to achieve this or
some links to the "Custom Resolver" thing ?

Thanks,
Jawher
Re: XML schema association [message #232030 is a reply to message #232015] Mon, 01 June 2009 18:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Look at the org.eclipse.wst.xsl.core plugin and particularly, the
org.eclipse.wst.xsl.core.resolver package.

http://dev.eclipse.org/viewcvs/index.cgi/sourceediting/plugi ns/org.eclipse.wst.xsl.core/src/org/eclipse/wst/xsl/core/res olver/?root=WebTools_Project

There is an extension point you need to implement which is done in the
plugin.xml for that particular plugin.

Dave

Jawher Moussa wrote:
> Hi,
> Sorry for hijacking this post, but I'm in the same situation : I want
> to use the SSE XML editor to edit an xml file which must obeys an xsd
> schema but without namespaces (no target namespace in the xsd, and no
> xmlns in the xml).
> Could David or somebody else give some hints on how to achieve this or
> some links to the "Custom Resolver" thing ?
>
> Thanks,
> Jawher
>
Re: XML schema association [message #232178 is a reply to message #232030] Fri, 05 June 2009 01:05 Go to previous messageGo to next message
Jawher Moussa is currently offline Jawher MoussaFriend
Messages: 10
Registered: July 2009
Junior Member
Hi again and thanks David :)

So, based on your hint, I created a resolver :

public class ResolverExtension implements URIResolverExtension {

public String resolve(IFile file, String baseLocation, String publicId,
String systemId) {
return new File("/home/djo/Desktop/article.xsd").toURI().toString();
}
}

declared it in plugin.xml :

<extension
point="org.eclipse.wst.common.uriresolver.resolverExtensions ">
<resolverExtension
class="xxx.core.ResolverExtension"
stage="prenormalization">
</resolverExtension>
</extension>

But then, when I hit Ctrl+space in an XML file, while the resolver
resolve method is called :

ResolverExtension.resolve(file=L/junk/NewFile.xml,
baseLocation= file:///home/djo/../runtime-EclipseApplication/junk/NewFile. xml,
publicId='', systemId='')

and I return a valid URI to a valid xsd schema file, no auto-completion
proposals are shown (except for the #comment and #XSL processing
instruction entries).

Am I missing something here ? What else should be configured to get
auto-completion in an xml file without having to reference the schema in
the xml using xmlns (and adding targetNamespace to the schema)

BTW, I'm using Eclipse Galileo SDK RC3 with :

* WST XML Core 3.1.0.v200901260254-7C7OFPeF7RZHIXHnTz0Jqc0

org.eclipse.wst.xml_core.feature.feature.group
Thanks and Cheers,
Jawher
Re: XML schema association [message #232195 is a reply to message #232178] Sat, 06 June 2009 00:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Well, a couple of things you may want to do.

1. Try putting your XSD in the plugin itself.
2. Once that is complete you can try the following bit of code that is
in the XSL Tools Resolver:

URL pluginURL = FileLocator.find(XSLCorePlugin.getDefault().getBundle(),
new Path("/xslt-schemas/xslt-1.0.xsd"), null); //$NON-NLS-1$
xslt_1_0_fileURL = FileLocator.toFileURL(pluginURL).toExternalForm();

That in particular gets the necessary XSLT schema to load.

Make sure that your plugin includes the schema folder where you have the
schema stored.

If you aren't getting content assistance, then the ContentModel is not
loading your schema. The basic XML content assistance gets it's entries
from those provided by the content model of your DTD or Schema.

Dave



Jawher Moussa wrote:
>
> Hi again and thanks David :)
>
> So, based on your hint, I created a resolver :
>
> public class ResolverExtension implements URIResolverExtension {
>
> public String resolve(IFile file, String baseLocation, String publicId,
> String systemId) {
> return new
> File("/home/djo/Desktop/article.xsd").toURI().toString();
> }
> }
>
> declared it in plugin.xml :
>
> <extension
> point="org.eclipse.wst.common.uriresolver.resolverExtensions ">
> <resolverExtension
> class="xxx.core.ResolverExtension"
> stage="prenormalization">
> </resolverExtension>
> </extension>
>
> But then, when I hit Ctrl+space in an XML file, while the resolver
> resolve method is called :
>
> ResolverExtension.resolve(file=L/junk/NewFile.xml,
> baseLocation= file:///home/djo/../runtime-EclipseApplication/junk/NewFile. xml,
> publicId='', systemId='')
>
> and I return a valid URI to a valid xsd schema file, no auto-completion
> proposals are shown (except for the #comment and #XSL processing
> instruction entries).
>
> Am I missing something here ? What else should be configured to get
> auto-completion in an xml file without having to reference the schema in
> the xml using xmlns (and adding targetNamespace to the schema)
>
> BTW, I'm using Eclipse Galileo SDK RC3 with :
>
> * WST XML Core 3.1.0.v200901260254-7C7OFPeF7RZHIXHnTz0Jqc0
>
> org.eclipse.wst.xml_core.feature.feature.group
> Thanks and Cheers,
> Jawher
>
Re: XML schema association [message #232203 is a reply to message #232195] Sat, 06 June 2009 00:05 Go to previous messageGo to next message
Jawher Moussa is currently offline Jawher MoussaFriend
Messages: 10
Registered: July 2009
Junior Member
Hi,

David Carver wrote:

> Well, a couple of things you may want to do.

> 1. Try putting your XSD in the plugin itself.
> 2. Once that is complete you can try the following bit of code that is
> in the XSL Tools Resolver:

> URL pluginURL = FileLocator.find(XSLCorePlugin.getDefault().getBundle(),
> new Path("/xslt-schemas/xslt-1.0.xsd"), null); //$NON-NLS-1$
> xslt_1_0_fileURL = FileLocator.toFileURL(pluginURL).toExternalForm();

> That in particular gets the necessary XSLT schema to load.

> Make sure that your plugin includes the schema folder where you have the
> schema stored.


I've already tried that, sorry for forgetting to mention it (and yes, the
schema folder is checked in the binary build section)

> If you aren't getting content assistance, then the ContentModel is not
> loading your schema. The basic XML content assistance gets it's entries
> from those provided by the content model of your DTD or Schema.

Does this mean that the xsd is not valid ? because it works well when I
add a targetNameSpace, register it as a catalog and reference it in an xml
with xmlns.


Thanks and Cheers,
Jawher



> Jawher Moussa wrote:
>>
>> Hi again and thanks David :)
>>
>> So, based on your hint, I created a resolver :
>>
>> public class ResolverExtension implements URIResolverExtension {
>>
>> public String resolve(IFile file, String baseLocation, String publicId,
>> String systemId) {
>> return new
>> File("/home/djo/Desktop/article.xsd").toURI().toString();
>> }
>> }
>>
>> declared it in plugin.xml :
>>
>> <extension
>> point="org.eclipse.wst.common.uriresolver.resolverExtensions ">
>> <resolverExtension
>> class="xxx.core.ResolverExtension"
>> stage="prenormalization">
>> </resolverExtension>
>> </extension>
>>
>> But then, when I hit Ctrl+space in an XML file, while the resolver
>> resolve method is called :
>>
>> ResolverExtension.resolve(file=L/junk/NewFile.xml,
>>
baseLocation= file:///home/djo/../runtime-EclipseApplication/junk/NewFile. xml,
>> publicId='', systemId='')
>>
>> and I return a valid URI to a valid xsd schema file, no auto-completion
>> proposals are shown (except for the #comment and #XSL processing
>> instruction entries).
>>
>> Am I missing something here ? What else should be configured to get
>> auto-completion in an xml file without having to reference the schema in
>> the xml using xmlns (and adding targetNamespace to the schema)
>>
>> BTW, I'm using Eclipse Galileo SDK RC3 with :
>>
>> * WST XML Core 3.1.0.v200901260254-7C7OFPeF7RZHIXHnTz0Jqc0
>>
>> org.eclipse.wst.xml_core.feature.feature.group
>> Thanks and Cheers,
>> Jawher
>>
Re: XML schema association [message #232210 is a reply to message #232203] Sat, 06 June 2009 12:42 Go to previous message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

No, but there may be an issue with handling XML Schemas without a
namespace and a schemaLocation using a resolver. The place that handles
loading and retrieving your Grammars based on the resolver is in the
following package:

org.eclipse.wst.xml.core.internal.modelquery

In particular you may want to set various break points in
XMLModelQueryAssociationProvider and XMLModelQueryImpl. You may also
need to set break points in the parent XMLAssociationProvider class.

I would also suggest opening a bug report as well, with samples of what
you are trying to do. Even though XML schema doesn't have a SystemID
or PublicID, you may need to set these in your resolver since you do not
have a namespace. You can use the name of the XSD as the identifier so
that the system can look it up in the cache, and load the grammar
accordingly. I believe the xml catalog resolver users the
schemalocation as either the systemId or PublicId when it is trying to
resolve the location of the xml without a namespace.

Dave


Jawher Moussa wrote:
> Hi,
>
> David Carver wrote:
>
>> Well, a couple of things you may want to do.
>
>> 1. Try putting your XSD in the plugin itself.
>> 2. Once that is complete you can try the following bit of code that is
>> in the XSL Tools Resolver:
>
>> URL pluginURL =
>> FileLocator.find(XSLCorePlugin.getDefault().getBundle(), new
>> Path("/xslt-schemas/xslt-1.0.xsd"), null); //$NON-NLS-1$
>> xslt_1_0_fileURL = FileLocator.toFileURL(pluginURL).toExternalForm();
>
>> That in particular gets the necessary XSLT schema to load.
>
>> Make sure that your plugin includes the schema folder where you have
>> the schema stored.
>
>
> I've already tried that, sorry for forgetting to mention it (and yes,
> the schema folder is checked in the binary build section)
>
>> If you aren't getting content assistance, then the ContentModel is not
>> loading your schema. The basic XML content assistance gets it's
>> entries from those provided by the content model of your DTD or Schema.
>
> Does this mean that the xsd is not valid ? because it works well when I
> add a targetNameSpace, register it as a catalog and reference it in an
> xml with xmlns.
>
>
> Thanks and Cheers,
> Jawher
>
>
>
>> Jawher Moussa wrote:
>>>
>>> Hi again and thanks David :)
>>>
>>> So, based on your hint, I created a resolver :
>>>
>>> public class ResolverExtension implements URIResolverExtension {
>>>
>>> public String resolve(IFile file, String baseLocation, String
>>> publicId,
>>> String systemId) {
>>> return new
>>> File("/home/djo/Desktop/article.xsd").toURI().toString();
>>> }
>>> }
>>>
>>> declared it in plugin.xml :
>>>
>>> <extension
>>> point="org.eclipse.wst.common.uriresolver.resolverExtensions ">
>>> <resolverExtension
>>> class="xxx.core.ResolverExtension"
>>> stage="prenormalization">
>>> </resolverExtension>
>>> </extension>
>>>
>>> But then, when I hit Ctrl+space in an XML file, while the resolver
>>> resolve method is called :
>>>
>>> ResolverExtension.resolve(file=L/junk/NewFile.xml,
> baseLocation= file:///home/djo/../runtime-EclipseApplication/junk/NewFile. xml,
>
>>> publicId='', systemId='')
>>>
>>> and I return a valid URI to a valid xsd schema file, no
>>> auto-completion proposals are shown (except for the #comment and #XSL
>>> processing instruction entries).
>>>
>>> Am I missing something here ? What else should be configured to get
>>> auto-completion in an xml file without having to reference the schema
>>> in the xml using xmlns (and adding targetNamespace to the schema)
>>>
>>> BTW, I'm using Eclipse Galileo SDK RC3 with :
>>>
>>> * WST XML Core 3.1.0.v200901260254-7C7OFPeF7RZHIXHnTz0Jqc0
>>>
>>> org.eclipse.wst.xml_core.feature.feature.group
>>> Thanks and Cheers,
>>> Jawher
>>>
>
Previous Topic:Axis 2 - 1.4
Next Topic:Classpath problem with Utility JAR Project
Goto Forum:
  


Current Time: Mon Dec 22 05:07:25 GMT 2014

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

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