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

Does not support XSD 1.1 #363

Open
bmix opened this issue Apr 28, 2019 · 6 comments · May be fixed by #515
Open

Does not support XSD 1.1 #363

bmix opened this issue Apr 28, 2019 · 6 comments · May be fixed by #515
Assignees
Labels
bug Something isn't working validation XSD

Comments

@bmix
Copy link

bmix commented Apr 28, 2019

With a document instance, that is specced with XSD v1.1, I just got:

cos-all-limited.2: The {max occurs} of an element in an 'all' model group must be 0 or 1. The value 'unbounded' for element 'Bcc' is invalid.

However, when validating with Xerces2 I get no complaints. Could it be, that XSD 1.1 is not supported?

@fbricon fbricon added bug Something isn't working XSD validation labels Apr 28, 2019
@fbricon
Copy link
Contributor

fbricon commented Apr 28, 2019

@bmix do you mind providing some sample documents reproducing the issue?

@bmix
Copy link
Author

bmix commented Apr 28, 2019

Thank you, for investigation.

When I open the following XSD in the oXygen XML IDE, using Xerces2 (offending place highlighted in image):

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
	xmlns:xs="http://www.w3.org/2001/XMLSchema" 
	xmlns:t="test" 
	xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" 
	targetNamespace="test" 
	elementFormDefault="qualified" 
	vc:minVersion="1.1">
	
	<xs:complexType name="testType">
		<xs:all>
			<xs:element name="testEle" minOccurs="1" maxOccurs="unbounded" type="xs:string"/>
			<xs:element name="testEleTwo" type="xs:string"/>
		</xs:all>
	</xs:complexType>
	
	<xs:element name="testDoc">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="testContainer" type="t:testType"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>

xsd

I get no problem shown. As soon, however, I remove the vc:minVersion="1.1" attribute (still in oXygen), effectively making it a 1.0 XSD, I get a:

The {max occurs} of an element in an 'all' model group must be 0 or 1. The value 'unbounded' for element 'testEle' is invalid.

This makes me conclude, that the error is bound to differences between 1.0 and 1.1 of XSD, as also indicated by this answer on Stack Overflow:

In XSD 1.0, the children of xs:all must have maxOccurs set to 1.

In XSD 1.1 this constraint is lifted.

When using the same data in VCode with Red Hat's XML Tools for this XML instance document (instance1.xml):

<?xml version="1.0" encoding="UTF-8"?>
<t:testDoc xmlns:t="test"
 xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="test file:/path/to/issue.xsd">
	<t:testContainer>
		<t:testEle>testEle0</t:testEle>
		<t:testEle>testEle1</t:testEle>
		<t:testEle>testEle2</t:testEle>
		<t:testEleTwo>testEleTwo0</t:testEleTwo>
	</t:testContainer>
</t:testDoc>

I get these two errors in VCode:

{
	"resource": "/path/to/instance1.xml",
	"owner": "_generated_diagnostic_collection_name_#1",
	"code": "cvc-complex-type.2.4.a",
	"severity": 8,
	"message": "Invalid element name:\n - testEle\n\nOne of the following is expected:\n - testEleTwo\n\nError indicated by:\n {test}\nwith code:",
	"source": "xml",
	"startLineNumber": 8,
	"startColumn": 4,
	"endLineNumber": 8,
	"endColumn": 13
}
{
	"resource": "path/to/instance1.xml",
	"owner": "_generated_diagnostic_collection_name_#1",
	"code": "cos-all-limited.2",
	"severity": 8,
	"message": "cos-all-limited.2: The {max occurs} of an element in an 'all' model group must be 0 or 1. The value 'unbounded' for element 'testEle' is invalid.",
	"source": "xml",
	"startLineNumber": 11,
	"startColumn": 11,
	"endLineNumber": 11,
	"endColumn": 11
}

@NikolasKomonen
Copy link
Contributor

NikolasKomonen commented May 2, 2019

I've looked into it and at the moment we don't support validation for XSD 1.1

Here are some references for when it is eventually worked on:

http://www.herongyang.com/XSD/Xerces2-Xsd11SchemaValidator-XSD-1-1-Validation.html
https://xerces.apache.org/xerces2-j/faq-xs.html

@angelozerr
Copy link
Contributor

AFter reading the great article https://blog.adamretter.org.uk/xerces-xsd11-maven/ the problem comes from the official xerces maven 2.12.0 which doesn't provide xsd1.1 although documentation says that 2.12.0 support xsd1.1 (see article for more explanation).

To fix the problem, we must switch from the official xerces maven 2.12.0 to org.exist-db.thirdparty.xerces. In other words replace https://github.com/angelozerr/lsp4xml/blob/master/org.eclipse.lsp4xml/pom.xml#L99 with

<dependency>
    <groupId>org.exist-db.thirdparty.xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.12.0</version>
    <classifier>xml-schema-1.1</classifier>
</dependency>

After this dependency change, the error with cos-all-limited.2 disappears with:

<xs:schema 
	xmlns:xs="http://www.w3.org/2001/XMLSchema" 
	xmlns:t="test" 
	xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" 
	targetNamespace="test" 
	elementFormDefault="qualified" 
	vc:minVersion="1.1">

If I change vc:minVersion to vc:minVersion="1.0", the error appears again.

@fbricon do you think we should change the xerces dependency? My fear is about IP Process for Eclipse.

@NikolasKomonen
Copy link
Contributor

@angelozerr @fbricon I'm trying this out and the tests fail with some OutOfMemory Java heap space errors.

I've tried in the root pom file to put something similar to:

<plugin>
    <configuration>
        <argLine>-Xmx1g</argLine>
        ....

But it doesn't work. Haven any of you seen this issue before?

@fbricon fbricon added this to the v0.8.0 milestone Jul 3, 2019
@angelozerr angelozerr linked a pull request Jul 17, 2019 that will close this issue
angelozerr added a commit that referenced this issue Jul 17, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
@angelozerr
Copy link
Contributor

@bmix I'm working on this issue with PR #515 It should be available for 0.8.0

angelozerr added a commit that referenced this issue Jul 17, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 17, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 17, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jul 17, 2019
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jul 17, 2019
angelozerr added a commit that referenced this issue Jul 17, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 18, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 18, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 18, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 18, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 18, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 18, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 19, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 19, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
@fbricon fbricon removed this from the v0.8.0 milestone Jul 22, 2019
@fbricon fbricon added this to the v0.9.0 milestone Jul 22, 2019
angelozerr added a commit that referenced this issue Jul 24, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
angelozerr added a commit that referenced this issue Jul 25, 2019
Fix #363

Signed-off-by: azerr <[email protected]>
@fbricon fbricon removed this from the v0.9.0 milestone Aug 20, 2019
alex-bel pushed a commit to alex-bel/lsp4xml that referenced this issue Jan 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working validation XSD
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants