我有静态XSD模式,我想用它来验证来自OAI-PMH端点的XML响应。
据说这个模式已经被验证了。
然而,当我尝试验证来自随机OAI-PMH端点的XML响应时,比如这个端点:
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="static/style.xsl"?>
<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
<responseDate>2019-07-29T13:29:04Z</responseDate>
<request verb="Identify">https://repository.lib.ncsu.edu/oai/driver</request>
<Identify>
<repositoryName>NCSU Repository</repositoryName>
<baseURL>https://repository.lib.ncsu.edu/oai/driver</baseURL>
<protocolVersion>2.0</protocolVersion>
<adminEmail>kdbeswic@ncsu.edu</adminEmail>
<earliestDatestamp>2006-11-10T15:53:37Z</earliestDatestamp>
<deletedRecord>transient</deletedRecord>
<granularity>YYYY-MM-DDThh:mm:ssZ</granularity>
<description>
<oai-identifier xmlns="http://www.openarchives.org/OAI/2.0/oai-identifier"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai-identifier http://www.openarchives.org/OAI/2.0/oai-identifier.xsd">
<scheme>oai</scheme>
<repositoryIdentifier>repository.lib.ncsu.edu</repositoryIdentifier>
<delimiter>:</delimiter>
<sampleIdentifier>oai:repository.lib.ncsu.edu:1840.20/1234</sampleIdentifier>
</oai-identifier>
</description>
</Identify>
</OAI-PMH>我明白这一例外:
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1055; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'oai-identifier'.
....我不知道为什么会发生这种情况,相关的线索也没有帮助我。请帮帮我。
发布于 2019-07-30 12:36:52
虽然xsd:any基本上允许任何XML元素,但它的@processContents属性给出了严格性的变化。在这种情况下,@processContents是strict,这意味着任何定义的元素都可能出现在那里。您的错误消息表明它无法找到oai-identifier元素的XSD定义。您可以通过执行以下操作之一来修复此问题:
xsd:any/@processContents更改为lax或skip;oai-identifier定义的验证XML解析器访问。也请参阅: 对于xsd:any,processContents严格的vs宽松的vs跳过的
注意:I能够成功地验证您发布的XML,而无需修改。我建议您再试一次,确保验证器能够访问每个所需的XSD(包括任何引用的XSD,临时的)。如果您有用于检索XSD的XML目录或其他重定向机制,请确保也检查这些机制。
https://stackoverflow.com/questions/57269516
复制相似问题