1

I have the static XSD schema, which I want to use to validate XML response against from an OAI-PMH endpoints.

It is said there that the schema is already validated.
Yet, when I try to validate XML response from a random OAI-PMH endpoint, such as this one:

<?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>

I get this exception:

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'.
....

I have no clue why does it happen and relevant threads didn't help me. Please help me.

improbable
  • 2,308
  • 2
  • 15
  • 28

1 Answers1

0

Although xsd:any will basically allow any XML element, there are variations of strictness given by its @processContents attribute. In this case, @processContents is strict, which means that any defined element may appear there. Your error message is indicating that it can find no such XSD definition for the oai-identifier element. You can fix this by doing one of the following:

  1. change the XML to present a defined element in that spot;
  2. change the XSD xsd:any/@processContents to lax or skip;
  3. provide the validating XML parser access to the definition of oai-identifier.

See also: processContents strict vs lax vs skip for xsd:any

Note: I was able to successfully validate your posted XML without modification. I suggest that you try again, making sure that the validator can access each of the required XSDs (including any referenced XSDs, transitively). If you have an XML catalog or other redirection mechanisms in place for retrieving XSDs, be sure to check those as well.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • I see, thanks. So the problematic element is `` under ``, is that right? Could you tell please also how to do 1 and 3 because I am not proficient in XML markup? – improbable Jul 30 '19 at 13:11
  • Yes, the default value for `@processContents` is `strict`. – kjhughes Jul 30 '19 at 13:32
  • Sanity check: replace `oai-identifier` with an element you know is defined in an accessible XSD, say, `repositoryName`. Then try revalidating. – kjhughes Jul 30 '19 at 13:36
  • I am not sure I am following you. How do I do that? `repositoryName` is already in the XML response. By the way, I am using this static XSD schema as a file in my project. – improbable Jul 30 '19 at 13:48
  • Via a code change or via an editor manually. I'm suggesting that you confirm that when you place a `repositoryName` element, which is established to be defined by an accessible XSD, in `description` whose content model allows any defined element, you are able to validate the resulting document successfully. If this is true, your issue has been narrowed to the accessibility of the definition of the `oai-identifier` element. – kjhughes Jul 30 '19 at 14:14
  • I put it like you said, block within `` tag, before `` block. Although IDEA told me that `Element repositoryName is not allowed here` I validated it regardless. I got this exception as a result of execution of this program `Invalid content was found starting with element 'repositoryName'. One of '{WC[##other:"http://www.openarchives.org/OAI/2.0/"]}' is expected.` What should I do next? – improbable Aug 05 '19 at 07:58
  • 1
    No, not *before* `oai-identifier`; *instead* of `oai-identifier`. I'm sorry, but we've crossed over from Q/A to diagnosis that requires more back-and-forth than is suitable to conduct here. The basic answer to your question is that your XML is valid against the linked XSDs. I've explained the meaning of `xsd:any/@processContents` and suggested that you further investigate a few options related to that constraint and the accessibility of the governing XSDs. Good luck. – kjhughes Aug 05 '19 at 12:12