XML with DTD and XML Schema [message #211233] |
Fri, 28 March 2008 03:24  |
Eclipse User |
|
|
|
Hi,
I have an XML that has a DTD declaration and also uses schemas with
different namespaces. The DTD contains only entity references while the
structure/grammar of the document is defined by schemas. While editing the
xml in the XML editor (bundled with WTP), the content assist and
validation work based only on the DTD. The schemas are ignored even if the
root element comes from one of the referenced schemas.
The content assist and every thing else work as desired (correct
proposals, warning, errors, etc) when the DTD declaration is removed. I
assume that when both DTD and XML schema are used in the instance
document, the XML editor considers only the DTD. Is it possible to
configure this feature so that both DTD and xml schemas are used. If need
be Ill extend SSE to provide an editor for the requirement. Any help is
greatly appreciated.
Thanks in advance.
|
|
|
|
|
|
|
Re: XML with DTD and XML Schema [message #211344 is a reply to message #211330] |
Sat, 29 March 2008 17:33  |
Eclipse User |
|
|
|
Originally posted by: dcarver.starstandard.org
You could dynamically load the DTD if you knew the content type for the
XML file (i.e. it's always a particular type like XSL, DOCBOOK, etc),
and then dynamically load the DTD based on content type.
I think a bug should be opened to request that if a DTD and a XML Schema
are referenced, that both content models should be available. I think
currently the code is doing one or the other, but there are plenty of
use cases like yours that will have the need to intermix the two.
Dave
x86core wrote:
> Thanks Dave. I am afraid I cannot take the xml catalog approach as the
> DTD changes with XML.I haven�t looked much into it yet, but with a
> little exploration I ended up looking at some code in
> org.eclipse.wst.xml.core plug-in. Of interest is the following snippet
> from
> org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimp l.CMDocumentLoader:
>
>
> public void loadCMDocuments()
> { //System.out.println("----------loadCMDocuments
> ------------");
> //long time = System.currentTimeMillis();
> boolean walkDocument = false;
> cmDocumentManager.removeAllReferences();
> String[] doctypeInfo =
> XMLAssociationProvider.getDoctypeInfo(document);
> if (doctypeInfo != null)
> {
> // load the doctype if required
> walkDocument = handleGrammar(doctypeInfo[0], doctypeInfo[1],
> "DTD"); //$NON-NLS-1$
> } else
> { Element element =
> getRootElement(document);
> if (element != null)
> {
> namespaceTable = new CMDocumentLoadingNamespaceTable(document);
> namespaceTable.addElement(element);
> if (namespaceTable.isNamespaceEncountered())
> { walkDocument = true;
> //System.out.println("isNamespaceAware");
> }
> else
> {
> namespaceTable = null;
> walkDocument = isInferredGrammarEnabled;
> //System.out.println("is NOT namespaceAware");
> } } }
> if (walkDocument)
> {
> visitNode(document); }
> //System.out.println("--- elapsed time (" + count + ") = " +
> (System.currentTimeMillis() - time));
> }
>
> Is it possible to make a few modifications (loaders and content assist
> classes) and achieve the desired behaviour? Or would the change span
> several classes with possible side-effects? It would be helpful to have
> some feedback. I could use my own build of the plug-ins until the
> feature is implemented. Thanks again.
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04078 seconds