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

No validation when referencing a schema in the same directory #144

Closed
fbricon opened this issue Sep 25, 2018 · 12 comments
Closed

No validation when referencing a schema in the same directory #144

fbricon opened this issue Sep 25, 2018 · 12 comments
Labels
bug Something isn't working validation
Milestone

Comments

@fbricon
Copy link
Contributor

fbricon commented Sep 25, 2018

Trying the example in https://stackoverflow.com/a/8780114/753170

resources.xsd:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:complexType name="property">
        <xs:attribute name="name" type="xs:string" />
        <xs:attribute name="value" type="xs:string" />
    </xs:complexType>

    <xs:complexType name="resource">
        <xs:sequence>
            <xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required" />
    </xs:complexType>

    <xs:element name="resources">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="resource" type="resource" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
            <xs:attribute name="variant" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

and resources.xml:

<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="resources.xsd"
        variant="X">
    <resource name="res00" >
        <property name="propA" value="..." />
        <property name="propB" value="..." />
    </resource>
    <resource name="res01" >
        <property name="propA" value="..." />
        <property name="propB" value="..." />
    </resource>
</resources>

resources.xml has an error on the opening resources tag:

cvc-elt.1.a: Cannot find the declaration of element 'resources'.

@fbricon fbricon added bug Something isn't working validation labels Sep 25, 2018
@angelozerr
Copy link
Contributor

angelozerr commented Sep 25, 2018

@fbricon
Copy link
Contributor Author

fbricon commented Sep 26, 2018

I still have the error, but completion for resource nodes and attributes work as expected. Weird

@angelozerr
Copy link
Contributor

I'm sorry @fbricon I cannot reproduce?

@angelozerr
Copy link
Contributor

@fbricon this issue is annoying because it works for me on Windows OS and tests https://github.com/angelozerr/lsp4xml/blob/master/org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/extensions/contentmodel/XMLSchemaDiagnosticsTest.java#L202 is passing.

@NikolasKomonen have you the same problem?

@fbricon
Copy link
Contributor Author

fbricon commented Oct 28, 2018

I still see this error. @NikolasKomonen please double check

@fbricon fbricon added this to the v0.0.2 milestone Oct 28, 2018
@angelozerr
Copy link
Contributor

@fbricon I can reproduce your issue!

To reproduce your problem, you need to open 2 XML files which are linked to an XML Schema which have no target namespace:

  • for instance open the invocie.xml. It stores in Xerces cache the XML Schema invoice.xsd with target namespace null as key (it's Xerces code)
  • open the resources.xml, it uses the ML Schema invoice.xsd that's why you have your bug.

To fix this bug, we need not to use Xerces cache. If you replace in XMLValidator, the line 50

XMLParserConfiguration configuration = new XMLGrammarCachingConfiguration();

with

XMLParserConfiguration configuration = new XIncludeAwareParserConfiguration();

Your bug dispareas, but we losse cache feature -( I would liek to keep cache feature, no find a solution for the moment.

angelozerr added a commit that referenced this issue Oct 29, 2018
@angelozerr
Copy link
Contributor

As WTP uses XIncludeAwareParserConfiguration, I decide to do the same thing.

@fbricon tell me if it fixes your problem.

@fbricon
Copy link
Contributor Author

fbricon commented Oct 29, 2018

can't we bind one parserconfiguration to one document? so that caching would be scoped to that particular document

angelozerr added a commit that referenced this issue Oct 30, 2018
@angelozerr
Copy link
Contributor

angelozerr commented Oct 30, 2018

can't we bind one parserconfiguration to one document? so that caching would be scoped to that particular document

Yes we could do that, but performances seems good, we will see if we need that in the future.

Is this issue is fixed for you @fbricon ?

@fbricon
Copy link
Contributor Author

fbricon commented Oct 31, 2018

Sanitizing the rootUri fixes this issue.

@angelozerr
Copy link
Contributor

Sanitizing the rootUri fixes this issue.

I don't understand, it should not be linked? I have fixed rootURI for file associations, but I'm sceptical that it fixes this issue? Please give me feedback.

@fbricon
Copy link
Contributor Author

fbricon commented Oct 31, 2018

You're right, this is irrelevant. It's working for me now anyway.

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
Projects
None yet
Development

No branches or pull requests

2 participants