|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
Originally posted by: dcarver.starstandard.org|
Jim Kremens wrote:
> This certainly sounds easier. But I'm not totally clear on how to do
> "You'll still have to have your editor pick up the correct catalog
> 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
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.
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:
Some information on DTDs is here:
Which you choose is up to you.
> Jim Kremens
> David Carver <email@example.com> 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
>> 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
>>> Right now I'm wrestling with whether I should do something like this:
>>> <extension point="org.eclipse.wst.xml.core.modelQueryExtensions">
>>> Or something like this
>>> <extension point="org.eclipse.wst.sse.core.modelHandler">
>>> 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!
|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
| Nitin Dahyabhai
Registered: July 2009
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.
Eclipse WTP Source Editing
Powered by FUDForum
. Page generated in 0.02853 seconds