-
Notifications
You must be signed in to change notification settings - Fork 93
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-model] XML Completion based on DTD/XML Schema by using xml-model #709
[xml-model] XML Completion based on DTD/XML Schema by using xml-model #709
Conversation
f870f7b
to
febde60
Compare
68bf321
to
0c7ac97
Compare
You can test this PR with this XML: <?xml-model href="http://maven.apache.org/xsd/maven-4.0.0.xsd" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0" >
</project> Open the completion and you should see pom completion: and hover: You can add several xml-model and benefit with completion for each grammar (according to the possible elements for xsd) but I don't understand how we could use it with dtd and xsd both. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to add some tests checking aggregation of documentation for tags, attributes...
...a/org/eclipse/lemminx/extensions/contentmodel/participants/ContentModelHoverParticipant.java
Outdated
Show resolved
Hide resolved
...a/org/eclipse/lemminx/extensions/contentmodel/participants/ContentModelHoverParticipant.java
Outdated
Show resolved
Hide resolved
...a/org/eclipse/lemminx/extensions/contentmodel/participants/ContentModelHoverParticipant.java
Outdated
Show resolved
Hide resolved
3d43176
to
eec1fcc
Compare
@fbricon I managed now aggregation with proper mean but I need to write test now. To try it you can open the grammar.xml (which defines 2 xml-model with a xsd and a dtd) that I have included in this PR and you hover the You should see: |
@fbricon please note you have in this case duplicate of completion item: I keep like this, because the apply completion could be different from the xsd or dtd (ex: xsd defines required attributes, the apply will insert from-xsd element with attributes. The from-xsd declared in the dtd doesn't declare attributes, it generate xsd-from without attributes). After discussing with @fbricon we keep this behavior. We will see if we will have some user issues with real usecases. |
eec1fcc
to
f355294
Compare
Test are written for hover aggregation. |
f355294
to
5c89989
Compare
@angelozerr I have an NPE when I have this xml:
with this xsd:
is my xsd file missing something? This is the error stack trace:
|
5c89989
to
5fc414c
Compare
Fixes eclipse-lemminx#698 Signed-off-by: azerr <azerr@redhat.com>
Those files belong to this PR (in the test xml-model folder). But here their content:
<!ELEMENT grammar (#PCDATA | from-dtd | from-xsd)* >
<!ELEMENT from-dtd (#PCDATA)>
<!-- DTD documentation for from-xsd -->
<!ELEMENT from-xsd (#PCDATA)>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="grammar">
<xs:complexType>
<xs:sequence>
<xs:element name="from-xsd" >
<xs:annotation>
<xs:documentation>XSD documentation for from-xsd</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml-model href="grammar.dtd" ?>
<?xml-model href="grammar.xsd" ?>
<grammar>
<from-xsd></from-xsd>
</grammar> |
The problem is that XSD must start with schema and not element. <schema xmlns='http://www.w3.org/2001/XMLSchema'>
<element name='element1'>
<complexType>
<sequence>
<element name='element1.1' type='string' />
<element name='element1.2' type='string' />
</sequence>
</complexType>
</element>
</schema> This NPE is not linked to this issue but it's a bug of Xerces. If you open the XSD file, you will see the same error. Please create an issue in LemMinx with this XSD which doesn't start with schema. I'm afraid that we cannot do something since it's a bug of Xerces. |
Oops sorry, I have missed that the first time around. The PR is working great on my end, I have also tested it with attribute tag/value completion from an external XSD and DTD |
Thanks for the review! |
[xml-model] XML Completion based on DTD/XML Schema by using xml-model
Fixes #698
Signed-off-by: azerr azerr@redhat.com