|
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 14:56 |
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 #224883 is a reply to message #224877] |
Wed, 10 December 2008 04:19 |
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 21:48 |
|
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 Web Tools Platform
|
|
|
Powered by
FUDForum. Page generated in 0.03436 seconds