Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [wtp-dev] Linking content type to XML schema

> On Aug 30, 2017, at 10:47 AM, Lucas Bullen <lbullen@xxxxxxxxxx> wrote:
> Hello,
> I am working on adding an XML editor within a plugin to enable completion assist for .csproj files when opened in this editor. Is there a way to associate this file extension with the XML catalogue entry or .xsd file directly without needing the file to specify the schema (avoid having to add the xmlns=".." part)?

There’s not a code-free way of doing it, and as a consequence you’ll
be calling internals to do this.

If you look at$
, it’s associating a CMDocumentFactory to a filename extension. The
supplied factory is given a URI to the file being edited in the
method to override, but the implementor could just delegate that
responsibility to an instance of
org.eclipse.wst.xsd.contentmodel.internal.CMDocumentFactoryXSD or
with a grammar URI of its choosing, the results of which it should
cache for subsequent requests. The biggest problems with that are 1)
you'll need a hard dependency on one of those content model plug-ins
and 2) neither of those factories expect to need to further resolve
the URI they’re given, as they’re usually called *after* any caching of
remote resources or lookups in the catalogue have happened.

A patch that wraps this into a new implementation class that does
take advantage of caching, supports the catalogue, and that makes
use of initialization data for the grammar URI would be well received,
I think.

Nitin Dahyabhai
Eclipse Web Tools Platform

Back to the top