Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Should I use modelHandler or modelQueryExtensions extension point for enhanced content assist?
Should I use modelHandler or modelQueryExtensions extension point for enhanced content assist? [message #224753] Fri, 05 December 2008 13:36 Go to next message
Jim Kremens is currently offline Jim Kremens
Messages: 8
Registered: July 2009
Junior Member
Hi all,

I want to enhance content assist to support custom tags and attributes
in html. I've posted before on a slightly different aspect of this
problem and the answer helped (thanks Keith Chong!) Having gotten my project
to work a little bit, I'm now trying to figure out the best way to
proceed...
Right now I'm wrestling with whether I should do something like this:

<extension point="org.eclipse.wst.xml.core.modelQueryExtensions">
<modelQueryExtension
class="org.fhtml.eclipse.editors.MyModelQueryExtension"
contentType="org.eclipse.wst.html.core.htmlsource">
</modelQueryExtension>
</extension>

Or something like this

<extension point="org.eclipse.wst.sse.core.modelHandler">
<modelHandler
default="yes"
class="org.fhtml.eclipse.editors.MyModelHandler"

associatedContentTypeId="org.eclipse.wst.html.core.htmlsource "
id="org.eclipse.wst.html.core.internal.modelhandler"> </modelHandler>
</extension>


I'm trying to weigh the benefits of each. Using the
'modelQueryExtensions' extension point seems to allow me to set custom attribute *values.*
But I think I'll need to use the 'modelHandler' extension to add my
own attribute *names* to the document structure. I'm looking for someone
to tell me whether this assumption is right or wrong.
Any advice would be greatly appreciated!

thanks,

Jim
Re: Should I use modelHandler or modelQueryExtensions extension point for enhanced content assist? [message #224762 is a reply to message #224753] Mon, 08 December 2008 09:56 Go to previous messageGo to next message
Eclipse User
Originally posted by: dcarver.starstandard.org

You could do your own version of the DTD for HTML and add your
extensions to that. If you add your attributes to the DTD they will
automatically be picked up by the existing grammars. You'll still have
to have your editor pick up the correct catalog contribution, but it
might be easier then trying to force the extensions through the model
handler.

Dave


Jim Kremens wrote:
>
> Hi all,
>
> I want to enhance content assist to support custom tags and attributes
> in html. I've posted before on a slightly different aspect of this
> problem and the answer helped (thanks Keith Chong!) Having gotten my project
> to work a little bit, I'm now trying to figure out the best way to
> proceed...
> Right now I'm wrestling with whether I should do something like this:
>
> <extension point="org.eclipse.wst.xml.core.modelQueryExtensions">
> <modelQueryExtension
> class="org.fhtml.eclipse.editors.MyModelQueryExtension"
> contentType="org.eclipse.wst.html.core.htmlsource">
> </modelQueryExtension>
> </extension>
>
> Or something like this
>
> <extension point="org.eclipse.wst.sse.core.modelHandler">
> <modelHandler
> default="yes"
> class="org.fhtml.eclipse.editors.MyModelHandler"
>
> associatedContentTypeId="org.eclipse.wst.html.core.htmlsource "
> id="org.eclipse.wst.html.core.internal.modelhandler"> </modelHandler>
> </extension>
>
>
> I'm trying to weigh the benefits of each. Using the
> 'modelQueryExtensions' extension point seems to allow me to set custom attribute *values.*
> But I think I'll need to use the 'modelHandler' extension to add my
> own attribute *names* to the document structure. I'm looking for someone
> to tell me whether this assumption is right or wrong.
> Any advice would be greatly appreciated!
>
> thanks,
>
> Jim
>
>
Re: Should I use modelHandler or modelQueryExtensions extension point for enhanced content assist? [message #224877 is a reply to message #224762] Tue, 09 December 2008 22:14 Go to previous messageGo to next message
Jim Kremens is currently offline Jim Kremens
Messages: 8
Registered: July 2009
Junior Member
This certainly sounds easier. But I'm not totally clear on how to do
this:
"You'll still have to have your editor pick up the correct catalog
contribution"
Although I know what XML Catalogs are, I'm not sure how to achieve what
you suggest. Any clarification or pointer to some appropriate links
would be great.
Thanks!

Jim Kremens

David Carver <dcarver@starstandard.org> wrote:
>You could do your own version of the DTD for HTML and add your
>extensions to that. If you add your attributes to the DTD they will
>automatically be picked up by the existing grammars. You'll still have
>to have your editor pick up the correct catalog contribution, but it
>might be easier then trying to force the extensions through the model
>handler.
>
>Dave
>
>
>Jim Kremens wrote:
>>
>> Hi all,
>>
>> I want to enhance content assist to support custom tags and attributes
>> in html. I've posted before on a slightly different aspect of this
>> to work a little bit, I'm now trying to figure out the best way to
>> proceed...
>> Right now I'm wrestling with whether I should do something like this:
>>
>> <extension point="org.eclipse.wst.xml.core.modelQueryExtensions">
>> <modelQueryExtension
>> class="org.fhtml.eclipse.editors.MyModelQueryExtension"
>> contentType="org.eclipse.wst.html.core.htmlsource">
>> </modelQueryExtension>
>> </extension>
>>
>> Or something like this
>>
>> <extension point="org.eclipse.wst.sse.core.modelHandler">
>> <modelHandler
>> default="yes"
>> class="org.fhtml.eclipse.editors.MyModelHandler"
>>
>> </extension>
>>
>>
>> I'm trying to weigh the benefits of each. Using the
>> But I think I'll need to use the 'modelHandler' extension to add my
>> own attribute *names* to the document structure. I'm looking for someone
>> to tell me whether this assumption is right or wrong.
>> Any advice would be greatly appreciated!
>>
>> thanks,
>>
>> Jim
>>
>>



--
Re: Should I use modelHandler or modelQueryExtensions extension point for enhanced content assist? [message #224883 is a reply to message #224877] Tue, 09 December 2008 23:19 Go to previous messageGo to next message
Eclipse User
Originally posted by: dcarver.starstandard.org

Jim Kremens wrote:
> This certainly sounds easier. But I'm not totally clear on how to do
> this:
> "You'll still have to have your editor pick up the correct catalog
> contribution"
> Although I know what XML Catalogs are, I'm not sure how to achieve what
> you suggest. Any clarification or pointer to some appropriate links
> would be great.

The way I would do it is create my own XML Schema or DTD for my
extensions. Then add an namespace entry into the HTML

<html xmlns:new="http://yournamespace.here.org/">

</html>

Then where you want to use your custom attributes, preceede it by new:

You'll want to register your Namespace with the XML Catalog so that the
HTML and XHTML editors will pick it up from the catalog. There is an
extension point in WTP to do this.

Once the namespace is registered, when the document is loaded it'll load
the appropriate grammar as well for the namespace, and you can get
content assistance with it.

The other way, is to use a Custom HTML DTD with your extensions
included. See this article on customizing the HTML DTD.

http://htmlhelp.com/tools/validator/customdtd.html

You then would have the DOCTYPE refer to your customized HTML DTD
instead of the standard HTML DTD.

You get a lot of customization by going with either DTD or XML Schema
grammars with your extensions.

An introduction to XML Schema:
http://www.xml.com/pub/a/2000/11/29/schemas/part1.html

Some information on DTDs is here:
http://www.xml.com/pub/a/2000/09/27/qanda.html

Which you choose is up to you.


> Thanks!
>
> Jim Kremens
>
> David Carver <dcarver@starstandard.org> wrote:
>> You could do your own version of the DTD for HTML and add your
>> extensions to that. If you add your attributes to the DTD they will
>> automatically be picked up by the existing grammars. You'll still have
>> to have your editor pick up the correct catalog contribution, but it
>> might be easier then trying to force the extensions through the model
>> handler.
>>
>> Dave
>>
>>
>> Jim Kremens wrote:
>>> Hi all,
>>>
>>> I want to enhance content assist to support custom tags and attributes
>>> in html. I've posted before on a slightly different aspect of this
>>> to work a little bit, I'm now trying to figure out the best way to
>>> proceed...
>>> Right now I'm wrestling with whether I should do something like this:
>>>
>>> <extension point="org.eclipse.wst.xml.core.modelQueryExtensions">
>>> <modelQueryExtension
>>> class="org.fhtml.eclipse.editors.MyModelQueryExtension"
>>> contentType="org.eclipse.wst.html.core.htmlsource">
>>> </modelQueryExtension>
>>> </extension>
>>>
>>> Or something like this
>>>
>>> <extension point="org.eclipse.wst.sse.core.modelHandler">
>>> <modelHandler
>>> default="yes"
>>> class="org.fhtml.eclipse.editors.MyModelHandler"
>>>
>>> </extension>
>>>
>>>
>>> I'm trying to weigh the benefits of each. Using the
>>> But I think I'll need to use the 'modelHandler' extension to add my
>>> own attribute *names* to the document structure. I'm looking for someone
>>> to tell me whether this assumption is right or wrong.
>>> Any advice would be greatly appreciated!
>>>
>>> thanks,
>>>
>>> Jim
>>>
>>>
>
>
>
Re: Should I use modelHandler or modelQueryExtensions extension point for enhanced content assist? [message #224923 is a reply to message #224753] Wed, 10 December 2008 16:48 Go to previous message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2142
Registered: July 2009
Senior Member
Jim Kremens wrote:
> I'm trying to weigh the benefits of each. Using the
> 'modelQueryExtensions' extension point seems to allow me to set custom attribute *values.*
> But I think I'll need to use the 'modelHandler' extension to add my
> own attribute *names* to the document structure. I'm looking for someone
> to tell me whether this assumption is right or wrong.
> Any advice would be greatly appreciated!

No, you can accomplish this with the same model query extension
class. Model Handlers have a 1:1 relationship with Content Types,
so it's really not a good idea to create a conflict. The results
would be unpredictable.

That said, with 3.0, the
ModelQueryExtension.getAvailableElementContent(Element, String, int)
method's final parameter, when equal to
ModelQuery.INCLUDE_ATTRIBUTES, can be used to return your own
CMAttributeDeclarations. Just keep in mind that ModelQueryExtension
is 1) still internal and 2) ties into many parts of the UI, so be
conscious of your extension's performance.

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Previous Topic:Which tools I need for quick and easy Web application creating?
Next Topic:Tomcat 6
Goto Forum:
  


Current Time: Fri Apr 25 02:50:10 EDT 2014

Powered by FUDForum. Page generated in 0.07430 seconds