Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Validation with GWT or other complex DOCTYPE - Error: Element type "ui:UiBinder" must be declared. #571

Open
RobertMolenda opened this issue Nov 24, 2020 · 9 comments

Comments

@RobertMolenda
Copy link

Validation Issues with {module}.ui.xml

Sample XML

<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:gxt="urn:import:com.sencha.gxt.widget.core.client.form"
xmlns:c="urn:import:com.blazent.web.client.widgets.controls"
xmlns:gxtcontainer="urn:import:com.sencha.gxt.widget.core.client.container"
xmlns:sl="urn:import:com.blazent.web.client.widgets.saveLoadOverlay"
xmlns:form="urn:import:com.sencha.gxt.widget.core.client.form" xmlns:w="urn:import:com.blazent.web.client.widgets"
xmlns:html="urn:import:com.blazent.web.client.widgets.html"
xmlns:button="urn:import:com.blazent.web.client.widgets.button"
xmlns:lists="urn:import:com.blazent.web.client.widgets.lists">
<g:HTMLPanel>
... page stuff here ...
</g:HTMLPanel>
</ui:UiBinder>

Error Message:
Element type "ui:UiBinder" must be declared.

Next Issue - Imbedded <!ENTITY records are not processed

Sample XML

  %HTMLlat1;
  <!ENTITY % HTMLsymbol SYSTEM 
  "https://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent">
  %HTMLsymbol;
  <!ENTITY % HTMLspecial SYSTEM 
  "https://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent">
  %HTMLspecial;
  ]>

<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" ...

In the file place   and it will be flagged as not being declared

I like the tool for Angular - but I also have to support GWT based projects -

Thanks
Robert Molenda

@mickaelistria
Copy link
Contributor

Can you please try latest snapshot from https://download.eclipse.org/wildwebdeveloper/snapshots/ and report whether this works or not?

@angelozerr
Copy link
Contributor

Element type "ui:UiBinder" must be declared.

At first I think you have this error because you declare DOCTYPE like:

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ui="urn:ui:com.google.gwt.uibinder"
    xmlns:g="urn:import:com.google.gwt.user.client.ui"
    xmlns:gxt="urn:import:com.sencha.gxt.widget.core.client.form"
    xmlns:c="urn:import:com.blazent.web.client.widgets.controls"
    xmlns:gxtcontainer="urn:import:com.sencha.gxt.widget.core.client.container"
    xmlns:sl="urn:import:com.blazent.web.client.widgets.saveLoadOverlay"
    xmlns:form="urn:import:com.sencha.gxt.widget.core.client.form"
    xmlns:w="urn:import:com.blazent.web.client.widgets"
    xmlns:html="urn:import:com.blazent.web.client.widgets.html"
    xmlns:button="urn:import:com.blazent.web.client.widgets.button"
    xmlns:lists="urn:import:com.blazent.web.client.widgets.lists">
  <g:HTMLPanel>
... page stuff here ...
</g:HTMLPanel>

</ui:UiBinder>

Is that?

I suggest you remove this DOCTYPE. At this step you will see no errors, no completion based on XSD. You need to write a XML catalog which defines a mapping between uri and XSD.

Create a XML file catalog gwt-catalog.xml like this :

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <uri
            name="urn:ui:com.google.gwt.uibinder"
            uri="http://dl.google.com/gwt/dtd/uibinder.xsd" />
    <uri
            name="urn:import:com.google.gwt.user.client.ui"
            uri="http://dl.google.com/gwt/dtd/com.google.gwt.user.client.ui.xsd" />
</catalog>

GWT Eclipse plugin does that too https:/gwt-plugins/gwt-eclipse-plugin/blob/d2478f8ca89d7c388442f810cec0a44f8962aa22/plugins/com.gwtplugins.gwt.eclipse.core/plugin.xml#L946

And after that you need to register the catalog with WWD preferences:

image

Once you did that, you can open your XML and you should benefit with completion based on XSD:

image

Please note that as UiBinder is defined in http://dl.google.com/gwt/dtd/uibinder.xsd as mixed:

    <xs:element
        name="UiBinder">
        <xs:complexType
            mixed="true">

you can write any element inside it (you will not have some error).

Next Issue - Imbedded <!ENTITY records are not processed

I suggest that you create an issue for that, because by default the XML Language Server disable the load of external entities (for security reason). You can enable it with xml.validation.resolveExternalEntities like we do in vscode-xml https:/redhat-developer/vscode-xml/blob/master/docs/Validation.md#resolve-external-entities but WWD doesn't provide this preference. Please create it.

@RobertMolenda
Copy link
Author

RobertMolenda commented Nov 25, 2020 via email

@RobertMolenda
Copy link
Author

RobertMolenda commented Nov 25, 2020 via email

@angelozerr
Copy link
Contributor

Unfortunately, the problem remains.

Which problems? You have again a validation problem even if you remove the DOCTYPE?

if you configure catalog, you should have completion based on XSD, no?

I hate when eclipse updates that it enables security that causes errors like this.

It's not Eclipse, it's the default behavior of the XML Language Server used https:/eclipse/lemminx/

It prevent from XXE atacks, see https://www.shielder.it/blog/2019/10/dont-open-that-xml-xxe-to-rce-in-xml-plugins-for-vs-code-eclipse-theia/

The only thing that WWD must provide is the settings xml.validation.resolveExternalEntities to enable resolve external entities which can be dangerous.

@mickaelistria
Copy link
Contributor

mickaelistria commented Nov 25, 2020

From Wild Web Developer, it looks like this is more a UX issue that a bug.
What I think is missing:

  • Some warning in the xmlns attributes to mention that it's not resolved
  • a quick fix/code action on such warning, to "configure XML catalogs", this could use a client-side command which the IDEs can decide to interpret at they want (eg showing the preference page for Eclipse IDE).

@angelozerr do you want me to open tickets to lemminx about that, or are those stories already covered is some way Wild Web Developer fails at leveraging?

For this example, I'd suggest @RobertMolenda you use actual XSD path (eg http://dl.google.com/gwt/dtd/uibinder.xsd ) in the xmlns elements instead of the "to be resolved" urn: ones.

@angelozerr
Copy link
Contributor

Some warning in the xmlns attributes to mention that it's not resolved

XML errors are reported by Xerces, and in this case, Xerces consider that it's a XML valid, because you can use namespace without XSD association. I think it's possible to support this warning, but I'm not sure it's an easy task.

When XML is not bound to a XSD, DTD grammar, you can see an information on the root element. The last release of LemMinx provides several code actions to generate XSD / DTD and associate it:

image

a quick fix/code action on such warning, to "configure XML catalogs", this could use a client-side command which the IDEs can decide to interpret at they want (eg showing the preference page for Eclipse IDE).

I think it's a new CodeAction that we should implement like we did to generate XSD, DTD. An idea is to generate the XML catalog and if LSP client have the capability,it can register the catalog on settings client side. We did this kind of feature when XML catalog path is wrong.

For this example, I'd suggest @RobertMolenda you use actual XSD path (eg http://dl.google.com/gwt/dtd/uibinder.xsd ) in the xmlns elements instead of the "to be resolved" urn: ones.

Why, XML catalogs is working for that, no? I'm not sure that @RobertMolenda want to modify the gwt xml which uses namespaces.

@mickaelistria
Copy link
Contributor

What's to be done on LSP4E on that matter? It seems like everything is in place to make it work.

@angelozerr
Copy link
Contributor

What's to be done on LSP4E on that matter? It seems like everything is in place to make it work.

For which feature?

To fix this issue WWD should provide the settings xml.validation.resolveExternalEntities to enable resolve external entities which can be dangerous. IMHO I think WWD should expose as UI preferences all LemMinx settings (enable codelens, format settings, etc) and settings which give the same behaviour than WTP editor (see #557).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants