1

我正在使用这个[1] XML Schema 来验证带有 xmllint 的 XML 文档:

xmllint --noout --schema mets.xsd metadata.xml

验证失败

metadata.xml:55: element object: Schemas validity error : Element '{info:lc/xmlns/premis-v2}object', attribute '{http://www.w3.org/2001/XMLSchema-instance}type': The QName value '{info:lc/xmlns/premis-v2}file' of the xsi:type attribute does not resolve to a type definition. 
metadata.xml:55: element object: Schemas validity error : Element '{info:lc/xmlns/premis-v2}object': The type definition is absent.

metadata.xml 中的第 55 行:

<premis:object xsi:type="premis:file" xsi:schemaLocation="info:lc/xmlns/premis-v2 http://www.loc.gov/standards/premis/v2/premis-v2-0.xsd">

但是,有一个我想要的示例文档。它位于此处[2]。

当我根据架构验证此示例时,会发生相同的验证错误。

louis-2-0.xml:80: element object: Schemas validity error : Element '{info:lc/xmlns/premis-v2}object', attribute '{http://www.w3.org/2001/XMLSchema-instance}type': The QName value '{info:lc/xmlns/premis-v2}file' of the xsi:type attribute does not resolve to a type definition.
louis-2-0.xml:80: element object: Schemas validity error : Element '{info:lc/xmlns/premis-v2}object': The type definition is absent.

我错过了什么?

[1] http://www.loc.gov/standards/mets/mets.xsd

[2] http://www.loc.gov/standards/premis/louis-2-0.xml

4

1 回答 1

0

The document you refer to as [2] is valid, so the error messages indicate a problem in your local setup. I'd guess that xmllint is not honoring the schema-location hint you quote from line 55, so it is not fetching the Premis schema and then is not finding the type mentioned.

To test that, try making a simple schema document that imports everthing you want to use, and use it to validate. Your document uses Mets and Premis, so we'll import those two schemas:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           elementFormDefault="qualified"> 

  <xs:import namespace="http://www.loc.gov/METS/"
     schemaLocation="http://www.loc.gov/standards/mets/mets.xsd"
  />

  <xs:import namespace="info:lc/xmlns/premis-v2"
    schemaLocation=
      "http://www.loc.gov/standards/premis/v2/premis-v2-0.xsd"
  />
</xs:schema>

Save this as mets-premis.xsd (or any name you like).

Now try validating with xmllint --noout --schema mets-premis.xsd metatdata.xml

于 2014-11-03T16:50:29.347 回答