Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » XML with DTD and XML Schema
XML with DTD and XML Schema [message #211233] Fri, 28 March 2008 07:24 Go to next message
exquisitus is currently offline exquisitusFriend
Messages: 3
Registered: July 2009
Junior Member
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 I’ll 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 #211280 is a reply to message #211233] Fri, 28 March 2008 15:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

I haven't tried this, but have you tried defining the entity declaration
within the XML itself and not calling the DTD. Does the content
assistance work for the XML schema as well as for the entity?

x86core wrote:
> 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 I�ll 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 #211287 is a reply to message #211280] Fri, 28 March 2008 16:55 Go to previous messageGo to next message
exquisitus is currently offline exquisitusFriend
Messages: 3
Registered: July 2009
Junior Member
Hi David,
The inline DTD does affect the content assist in some way; it appears to
offer completion for elements only. However that is not what I was looking
for. To be precise, in my case it is required to separate out the entity
declaration into an external DTD and reference them in the xml. I would
like the content assist to look up the DTD and the XML schema as well. If
that were not possible, then ignore the DTD (since it has entity
declarations only) and offer content assistance for the namespace(d)
elements in XML. Is there a preference setting that I am overlooking? Or
is it possible to accomplish by extending the XML editor?
Thanks.
Re: XML with DTD and XML Schema [message #211292 is a reply to message #211287] Fri, 28 March 2008 17:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Have you tried adding your DTD's public identifer to the XML catalog....
I think you may have to open a bug/enhancement request for this feature,
as I don't think the current loaders support both DTD and XSD mixtures.
You might be able to get around it by adding your DTD to a XML
catalog, and the same with your XSD. This way when you hit the
namespace for your XSD it can load via the namespace.

Dave

x86core wrote:
> Hi David,
> The inline DTD does affect the content assist in some way; it
> appears to offer completion for elements only. However that is not what
> I was looking for. To be precise, in my case it is required to separate
> out the entity declaration into an external DTD and reference them in
> the xml. I would like the content assist to look up the DTD and the XML
> schema as well. If that were not possible, then ignore the DTD (since it
> has entity declarations only) and offer content assistance for the
> namespace(d) elements in XML. Is there a preference setting that I am
> overlooking? Or is it possible to accomplish by extending the XML
> editor? Thanks.
>
>
Re: XML with DTD and XML Schema [message #211330 is a reply to message #211292] Sat, 29 March 2008 14:46 Go to previous messageGo to next message
exquisitus is currently offline exquisitusFriend
Messages: 3
Registered: July 2009
Junior Member
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.
Re: XML with DTD and XML Schema [message #211344 is a reply to message #211330] Sat, 29 March 2008 21:33 Go to previous message
Eclipse UserFriend
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.
>
>
Previous Topic:Re: Publishing error on a dynamic web app project
Next Topic:JavaScript Debugging by URL not available
Goto Forum:
  


Current Time: Fri Dec 19 10:11:34 GMT 2014

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

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