|assigning DTD to XML doc without specifying it in XML itself [message #192939]
||Tue, 22 May 2007 06:00
Originally posted by: neerajkarandikar.gmail.com|
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.
|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
| Craig Salter
Registered: July 2009
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!
> 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?
> "craig" <email@example.com> wrote in message
>> Yeah it's possible (at least the way I'm interpretting what you're asking
>> 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 . Also take a look at plugin
>> org.eclipse.wst.html.standard.dtds. That should give you a good example
>> that you can copy/paste for your own needs.
>> good luck!
>> neeraj wrote:
>>> 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.
Powered by FUDForum
. Page generated in 0.02078 seconds