Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » assigning DTD to XML doc without specifying it in XML itself
assigning DTD to XML doc without specifying it in XML itself [message #192939] Tue, 22 May 2007 06:00 Go to next message
Eclipse UserFriend
Originally posted by: neerajkarandikar.gmail.com

Hi,

I have various XML documents in my plug-in which use default XML editor.
Each of these documents have a DTD stored somewhere in my workspace. I want
to validate these XMLs using the DTD without specifying them in the XML
docuement it self but my plug-in should take care of finding this DTD
depending upon editor instance and validating XML document against
respective DTD. Is that possible?

Thanks a lot for your help.
Neeraj
Re: assigning DTD to XML doc without specifying it in XML itself [message #193070 is a reply to message #192939] Fri, 25 May 2007 06:26 Go to previous messageGo to next message
Craig Salter is currently offline Craig SalterFriend
Messages: 169
Registered: July 2009
Senior Member
Yeah it's possible (at least the way I'm interpretting what you're asking
for).

You can specify an extension in your plugin.xml to map a DTD (that can
live in your plugin) to a particular publicId or systemId 'key'. In the
case of a systemId this is usually an actual or hypothetical web address
(e.g. http://www.example.org/stuff/foo.dtd). Then your XML instance files
just need to include a DOCTYPE that specifies the 'keyed' publicId or
systemId. This way you'll avoid having to put the DTD in your workspace.
We register lots of industry standard XML Schema and DTDs files in WTP
this way.

Take a look at the XML Catalog tutorial [1]. Also take a look at plugin
named
org.eclipse.wst.html.standard.dtds. That should give you a good example
that you can copy/paste for your own needs.

good luck!
craig

[1]
http://www.eclipse.org/webtools/community/tutorials/XMLCatal og/XMLCatalogTutorial.html

neeraj wrote:

> Hi,

> I have various XML documents in my plug-in which use default XML editor.
> Each of these documents have a DTD stored somewhere in my workspace. I want
> to validate these XMLs using the DTD without specifying them in the XML
> docuement it self but my plug-in should take care of finding this DTD
> depending upon editor instance and validating XML document against
> respective DTD. Is that possible?

> Thanks a lot for your help.
> Neeraj
Re: assigning DTD to XML doc without specifying it in XML itself [message #193387 is a reply to message #193070] Tue, 29 May 2007 04:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: neerajkarandikar.gmail.com

Hi Craig,

Thanks for your reply.

The problem at my end is we have lots of old XML docs without DOCTYPE
definition present in them. Now, we want these documents to be validated
against a specified DTD from within eclipse runtime without actually
mentioning the DOCTYPE definition in all those documents.

The way we want to do this is to keep a DTD document somewhere accessible
from eclipse env. Then on Read / Save / Modify(show Content

assist) of typical XML documents parse these document against that DTD.

Also we use the eclipse default XML editor for editing these documents.

Is there any way to achieve this?

Thanks,

Neeraj

"craig" <csalter@ca.ibm.com> wrote in message
news:a024f46e8466ed205c3aa39b25b4532a$1@www.eclipse.org...
> Yeah it's possible (at least the way I'm interpretting what you're asking
> for).
> You can specify an extension in your plugin.xml to map a DTD (that can
> live in your plugin) to a particular publicId or systemId 'key'. In the
> case of a systemId this is usually an actual or hypothetical web address
> (e.g. http://www.example.org/stuff/foo.dtd). Then your XML instance files
> just need to include a DOCTYPE that specifies the 'keyed' publicId or
> systemId. This way you'll avoid having to put the DTD in your workspace.
> We register lots of industry standard XML Schema and DTDs files in WTP
> this way.
>
> Take a look at the XML Catalog tutorial [1]. Also take a look at plugin
> named
> org.eclipse.wst.html.standard.dtds. That should give you a good example
> that you can copy/paste for your own needs.
>
> good luck!
> craig
>
> [1]
> http://www.eclipse.org/webtools/community/tutorials/XMLCatal og/XMLCatalogTutorial.html
>
> neeraj wrote:
>
>> Hi,
>
>> I have various XML documents in my plug-in which use default XML editor.
>> Each of these documents have a DTD stored somewhere in my workspace. I
>> want to validate these XMLs using the DTD without specifying them in the
>> XML docuement it self but my plug-in should take care of finding this DTD
>> depending upon editor instance and validating XML document against
>> respective DTD. Is that possible?
>
>> Thanks a lot for your help.
>> Neeraj
>
Re: assigning DTD to XML doc without specifying it in XML itself [message #193628 is a reply to message #193387] Wed, 30 May 2007 13:37 Go to previous message
Craig Salter is currently offline Craig SalterFriend
Messages: 169
Registered: July 2009
Senior Member
Currently you can only get proper grammar support (validation, content
assist, etc.) for an xml file that specifies a DOCTYPE, xml namespace or
xsi:schemaLocation / xsi:noNamespaceSchemaLocation. Unless you've got one
of those the validator and editor don't know how to find your grammar.
It'd be useful to see a 'sample' of your file to verify that your use case
is a lost cause.

BTW, It's possible that the validator and editor *could* be enhanced to
consider the root element name and use the XML Catalog to look up a
grammar registered for the root element. However, that sounds like a
significant code change and testing effort. Until someone volunteers to
take on such an effort, I'd recommend just modifying your XML files to
provide grammar information (such as a DOCTYPE in the DTD case).

hope that helps!


neeraj wrote:

> Hi Craig,

> Thanks for your reply.

> The problem at my end is we have lots of old XML docs without DOCTYPE
> definition present in them. Now, we want these documents to be validated
> against a specified DTD from within eclipse runtime without actually
> mentioning the DOCTYPE definition in all those documents.

> The way we want to do this is to keep a DTD document somewhere accessible
> from eclipse env. Then on Read / Save / Modify(show Content

> assist) of typical XML documents parse these document against that DTD.

> Also we use the eclipse default XML editor for editing these documents.

> Is there any way to achieve this?

> Thanks,

> Neeraj

> "craig" <csalter@ca.ibm.com> wrote in message
> news:a024f46e8466ed205c3aa39b25b4532a$1@www.eclipse.org...
>> Yeah it's possible (at least the way I'm interpretting what you're asking
>> for).
>> You can specify an extension in your plugin.xml to map a DTD (that can
>> live in your plugin) to a particular publicId or systemId 'key'. In the
>> case of a systemId this is usually an actual or hypothetical web address
>> (e.g. http://www.example.org/stuff/foo.dtd). Then your XML instance files
>> just need to include a DOCTYPE that specifies the 'keyed' publicId or
>> systemId. This way you'll avoid having to put the DTD in your workspace.
>> We register lots of industry standard XML Schema and DTDs files in WTP
>> this way.
>>
>> Take a look at the XML Catalog tutorial [1]. Also take a look at plugin
>> named
>> org.eclipse.wst.html.standard.dtds. That should give you a good example
>> that you can copy/paste for your own needs.
>>
>> good luck!
>> craig
>>
>> [1]
>>
http://www.eclipse.org/webtools/community/tutorials/XMLCatal og/XMLCatalogTutorial.html
>>
>> neeraj wrote:
>>
>>> Hi,
>>
>>> I have various XML documents in my plug-in which use default XML editor.
>>> Each of these documents have a DTD stored somewhere in my workspace. I
>>> want to validate these XMLs using the DTD without specifying them in the
>>> XML docuement it self but my plug-in should take care of finding this DTD
>>> depending upon editor instance and validating XML document against
>>> respective DTD. Is that possible?
>>
>>> Thanks a lot for your help.
>>> Neeraj
>>
Previous Topic:running apache tomcat 5.5 under eclipse behaves differently than at the command line (on windows)
Next Topic:2nd level dependencies not being included in .war file
Goto Forum:
  


Current Time: Sun Dec 21 18:02:05 GMT 2014

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

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