Skip to content

Validation difference 3.4.5 -> 4.0.0 #446

@FredrikWendt

Description

@FredrikWendt

I've noticed a difference in behaviour between versions 3.4.5 and 4.0.0, that I couldn't read myself to understanding. Either I stumbled upon an unintentional bug, or this becomes a request to clarify the difference between major version 3 and 4 of this library.

I'm quite the amateur when it comes to XML Schema details. My objective is to produce XML that conforms to a schema specified by a service provider. Since version 4.0.0, the schema I use to validate against is no longer valid - it can't be parsed by this library anymore.

I have two workarounds:

  • pin the version of xmlschema to 3.4.5
  • use version 4.0.0 but add validation='lax' when loading the schema(s)

The error I get is this:

>           raise error
E           xmlschema.validators.exceptions.XMLSchemaParseError: selector xpath expression can only select elements:
E           
E           Schema component:
E           
E             <xs:keyref xmlns:xs="http://www.w3.org/2001/XMLSchema" name="fk-mainLocation" refer="key-location">
E               <xs:selector xpath="." />
E               <xs:field xpath="@mainLocation" />
E             </xs:keyref>
E           
E           Path: /xs:schema/xs:element/xs:complexType/xs:sequence/xs:element/xs:keyref
E           
E           Schema URL: file:///Users/....../edumedia/schema-files/xml-import.xsd

The Schema URL file is a local copy of this: https://github.com/keghub/xml-import/blob/master/schemas/3.0/xml-import.xsd

Here's a repo to quickly reproduce this difference between 3.4.5 and 4.0.0: https://github.com/FredrikWendt/xmlschema-issue

Is this change in behaviour by design? I looked through the CHANGELOG to look for changes, but I don't see it. While I'm fully aware moving to 4.x is a major release, I would love/appreciate some notes describing changes from 3 to 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions