Skip to content

xmllint failing on ccmm_sample due to wrong schemaLocation #92

@roman-dvorak

Description

@roman-dvorak

Dobrý den,

When trying to validate the provided CCMM sample XML file against the CCMM schema using xmllint:

xmllint --noout --schema dataset/schema.xsd ccmm_sample.xml

Ends with this errors:

error : Unknown IO error
warning: failed to load external entity "http://www.w3.org/XML/1998/namespace"
language-system/schema.xsd:3: element import: Schemas parser warning : Element '{http://www.w3.org/2001/XMLSchema}import': Failed to locate a schema at location 'http://www.w3.org/XML/1998/namespace'. Skipping the import.
...

The issue is that XSD files import the XML namespace like this:

<xs:import namespace="http://www.w3.org/XML/1998/namespace"
           schemaLocation="http://www.w3.org/XML/1998/namespace"/>

SchemaLocation assumes that there is link to XSD file. The correct schema file ('schemaLocitain' atribut) is http://www.w3.org/2001/xml.xsd.

How to solve this issue manually

Replace all occurrences of

schemaLocation="http://www.w3.org/XML/1998/namespace"

with

schemaLocation="http://www.w3.org/2001/xml.xsd"

This can be replaced manually with sed command with:

grep -rl --include='*.xsd' 'schemaLocation="http://www.w3.org/XML/1998/namespace"' . \
| xargs sed -i.bak \
  's|schemaLocation="http://www.w3.org/XML/1998/namespace"|schemaLocation="http://www.w3.org/2001/xml.xsd"|g'

After this fix, the validation is succeessful:

xmllint --noout --schema dataset/schema.xsd ccmm_sample.xml
ccmm_sample.xml validates

I would like to add some instructions to the README or Wiki, how we can validate our own schema using the xmllint tool.

_I hope this hasn’t already been solved or discussed somewhere else, I can't find it.

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