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

Support completion with xs:any #177

Closed
tenluap opened this issue Aug 8, 2019 · 25 comments
Closed

Support completion with xs:any #177

tenluap opened this issue Aug 8, 2019 · 25 comments
Assignees
Labels
Milestone

Comments

@tenluap
Copy link

tenluap commented Aug 8, 2019

I just noticed that the intellisense is broken in the latest version.
I had to reverse back to version 0.6.0 which works very well and also the validator fails too.

Please kindly review this issue and thanks for this nice extension.

@tenluap tenluap changed the title Intellisense now work on xml files with custom .xsd Intellisense and validator not working on xml files with custom .xsd Aug 8, 2019
@fbricon
Copy link
Collaborator

fbricon commented Aug 8, 2019

Please provide sample files reproducing the issue.

@tenluap
Copy link
Author

tenluap commented Aug 8, 2019

sample.zip

Also on the lower versions no validator is working

@fbricon
Copy link
Collaborator

fbricon commented Aug 8, 2019

How did you associate the xsd to the xml? file association setting? catalog?

@fbricon
Copy link
Collaborator

fbricon commented Aug 8, 2019

Ok, I can reproduce with

  "xml.fileAssociations": [
      {
          "pattern": "**/*.xml",
          "systemId": "tns.xsd"
      }
  ]

@NikolasKomonen something you could check?

@fbricon fbricon added bug Something isn't working completion validation xsd labels Aug 8, 2019
@fbricon
Copy link
Collaborator

fbricon commented Aug 8, 2019

So I get completion under the root (most if not all elements), under the ActionBar element (ActionBar.actionItems), nothing under Page or ScrollView.

Relates to eclipse-lemminx/lemminx#180

@tenluap
Copy link
Author

tenluap commented Aug 8, 2019

Just also noticed that validation works on the first tag/root tag but fails on the inner tags.

@angelozerr
Copy link
Contributor

@ehigiepaul could you please give us XML samples which doesn't work with completion and validation because in my case it works:

  • For completion (see cursor position with |)
<Action | <-- here ActionBar is opened)
<ActionBar>
    | <-- here ActionBar.actionItems is opened
</ActionBar>
<ActionBar>
    <ActionBar.actionItems>
        | <-- here ActionItem is opened
    </ActionBar.actionItems>
</ActionBar>
  • for validation it works too:

image

@angelozerr
Copy link
Contributor

nothing under Page or ScrollView.

For elements, yes it's normal (according XML Schema), there are only attributes for thoses elements (completion on attribute should work).

@tenluap
Copy link
Author

tenluap commented Aug 9, 2019

Please kinld reverse to version 0.6.0 and run the xsd and see intellisense works well and validations work only on the root element. But on version 0.8.0 all fails.

@angelozerr
Copy link
Contributor

angelozerr commented Aug 9, 2019 via email

@tenluap
Copy link
Author

tenluap commented Aug 9, 2019

Here is the sample
https://github.com/redhat-developer/vscode-xml/files/3482737/sample.zip

This is what i get on the current version 0.8.0 .

  • I get attributes on every tag, ✔
  • Validation is present only on the root tag ✔
  • No validation on inner tags attributes ❌
  • No tag suggestions.❌

version 0 8 0 err

here is what i get on version 0.6.0.

  • I get attributes on every tag, ✔
  • Validation is present only on the root tag ✔
  • No validation on inner tags attributes ❌
  • Tag suggestions works ✔

version 0 6 0

@skjardenCode
Copy link

skjardenCode commented Aug 10, 2019

Hi,

I have the same problem with XML validation.

VS Code Version: 1.36.1
XML Language Support Version: 0.8.0

XML to validate:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cpr xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://www.dgai.de/cpr/schema/ev/cpr-ev-2.0.xsd">
<cprev>
        <VERSION>2.0</VERSION>
        <DATUM>2019-08-09</DATUM>
        <STOKENN>stokenn001</STOKENN>
        <EWZ>00000000</EWZ>
        <PATID>000000000000000</PATID>
        <PROTAR>01</PROTAR>
        <GEBDAT>asd</GEBDAT>
        <PATALTER>999:9999</PATALTER>
        <EOKO>00</EOKO>
        <PACER>06</PACER>
        <FBSYSTEM>06</FBSYSTEM>
        <AUTOCPR>06</AUTOCPR>
        <NTECH>02</NTECH>
        <ROSC>98</ROSC>
        <KHAUF>98</KHAUF>
        <KVEN>999</KVEN>
	<NACHFNA>02</NACHFNA>
    </cprev>
</cpr>

There are numerous problems with the above XML:

cvc-pattern-valid: Value 'stokenn001' is not facet-valid with respect to pattern '[0-9]{8}' for type 't_STOKENN'.
cvc-type.3.1.3: The value 'stokenn001' of element 'STOKENN' is not valid.
cvc-datatype-valid.1.2.2: 'asd' is not a valid value of list type 't_GEBDAT'.
cvc-type.3.1.3: The value 'asd' of element 'GEBDAT' is not valid.
cvc-datatype-valid.1.2.2: '999:9999' is not a valid value of list type 't_PATALTER'.
cvc-type.3.1.3: The value '999:9999' of element 'PATALTER' is not valid.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'EOKO'. One of '{"":PAEDALT, "":GESCHL}' is expected.
cvc-length-valid: Value '999' with length = '3' is not facet-valid with respect to length '2' for type 't_KVEN'.
cvc-type.3.1.3: The value '999' of element 'KVEN' is not valid.

But the extension does not recognize any of those XML validation errors.

Please say if I can be of any further help.

@angelozerr
Copy link
Contributor

@ehigiepaul thanks for the demo i can reproduce it

@skjardenCode please create à new issue with your xml validation problem

@angelozerr
Copy link
Contributor

@ehigiepaul since 0.8.0 completion show possible elements instead of showing all elements. See Accurate XSD-based completion in https://developers.redhat.com/blog/2019/07/24/whats-new-in-the-visual-studio-code-xml-extension/

Your XML Schema is using xs:any (<xs:any processContents="skip" minOccurs="0" maxOccurs="1" />):

<xs:complexType name="ContentView">
    <xs:complexContent>
      <xs:extension base="View">
        <xs:sequence>
          <xs:any processContents="skip" minOccurs="0" maxOccurs="1" />
        </xs:sequence>
        <xs:attributeGroup ref="contentViewAttributes" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

It is this case with xs:any which is not managed. I'm fixing it.

For validation, it's because you are using <xs:any processContents="skip" which means that validation is skipped. if you change with <xs:any processContents="lax" you should have validation.

@skjardenCode there is indeed a bug with your XML usecase, please create à new issue and I will fix it as soon as you will create the issue.

@angelozerr
Copy link
Contributor

@skjardenCode please see eclipse-lemminx/lemminx#553 for your problem which will be fixed by @NikolasKomonen

@tenluap
Copy link
Author

tenluap commented Aug 13, 2019

@angelozerr thanks for the processContents fix for validation. Works fine.
But still in version 0.8.0 intellisense or tag suggestion issue need to be fixed

@angelozerr
Copy link
Contributor

@angelozerr thanks for the processContents fix for validation. Works fine.

You are welcome!

But still in version 0.8.0 intellisense or tag suggestion issue need to be fixed

Yes sure, I will work on that. But I think we should show all XML element declared in XML file when xs:any is used. I mean XML element coming from XML Schema and custom XML Element.

For instance, if we have:

<Page>
  <a />
  <ScrollView>
    | <-- here completion must show Page, Scrollview, ContentView (from XML Schema) and <a /> (custom XML element)

@tenluap
Copy link
Author

tenluap commented Aug 13, 2019

@angelozerr version report now after your quick xsd fix

This is what i get on the current version 0.8.0 .
attributes on every tag, ✔
Validation on the root tag ✔
validation on inner tags attributes ✔
tag suggestions.❌

here is what i get on version 0.6.0.
attributes on every tag, ✔
Validation on the root tag ✔
validation on inner tags attributes ✔
Tag suggestions works ✔

I

@tenluap
Copy link
Author

tenluap commented Aug 19, 2019

Any hope on the fix

@angelozerr angelozerr changed the title Intellisense and validator not working on xml files with custom .xsd Support completion with xs:any Aug 20, 2019
@angelozerr
Copy link
Contributor

I'm working on this issue.

@fbricon fbricon added this to the 0.9.0 milestone Aug 20, 2019
angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Aug 20, 2019
See redhat-developer/vscode-xml#177

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Aug 20, 2019
See redhat-developer/vscode-xml#177

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Aug 20, 2019
See redhat-developer/vscode-xml#177

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Aug 20, 2019
See redhat-developer/vscode-xml#177

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Aug 22, 2019
See redhat-developer/vscode-xml#177

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Aug 22, 2019
See redhat-developer/vscode-xml#177

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Aug 22, 2019
See redhat-developer/vscode-xml#177

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Aug 22, 2019
See redhat-developer/vscode-xml#177

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Aug 22, 2019
See redhat-developer/vscode-xml#177

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr
Copy link
Contributor

Fixed with eclipse-lemminx/lemminx#559

@fbricon
Copy link
Collaborator

fbricon commented Aug 22, 2019

Completion returns duplicates from already inserted elements from the xsd:

Screen Shot 2019-08-22 at 6 17 39 PM

Using https://github.com/redhat-developer/vscode-xml/files/3482737/sample.zip

@fbricon fbricon reopened this Aug 22, 2019
@angelozerr
Copy link
Contributor

@fbricon good catch. Please review my PR eclipse-lemminx/lemminx#563 which fixes this duplicate issue.

@angelozerr
Copy link
Contributor

Completion returns duplicates from already inserted elements from the xsd:

Fixed with eclipse-lemminx/lemminx#563

@mickaelistria
Copy link

mickaelistria commented Mar 5, 2020

IMO, schema completion in xs:any should only be provided when processContents is not skip. See eclipse-lemminx/lemminx#612 for example and rationale. The semantic of processContents is explicit enough to tell that no schema-related features (including completion) should be involved when set to skip.

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

No branches or pull requests

5 participants