# XML API results do not validate against the schema

**URL:** <https://community.crossref.org/t/xml-api-results-do-not-validate-against-the-schema/2858>\
**Category:** Technical Support\
**Tags:** schema, metadata-retrieval, xml\_api\
**Created:** [2 August 2022 20:40 UTC](https://community.crossref.org/t/xml-api-results-do-not-validate-against-the-schema/2858 "2022-08-02T20:40:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ialarmedalien](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@ialarmedalien](https://community.crossref.org/u/ialarmedalien)\
**Post date:** [2 August 2022 20:40 UTC](https://community.crossref.org/t/xml-api-results-do-not-validate-against-the-schema/2858/1 "2022-08-02T20:40:52Z")

</div>

doi: 10.46936/10.25585/60000611  
request results as `unixsd`, i.e. using the schema `crossref_query_output3.0.xsd`

validate results against xsd using the online validator at `utilities-online.info` gives the errors:

> - Element ‘{http www crossref org/qrschema/3.0}doi’, attribute ‘type’: [facet ‘enumeration’] The value ‘grant’ is not an element of the set {‘journal\_title’, ‘journal\_issue’, ‘journal\_volume’, ‘journal\_article’, ‘conference\_title’, ‘conference\_series’, ‘conference\_paper’, ‘book\_title’, ‘book\_series’, ‘book\_content’, ‘component’, ‘dissertation’, ‘report-paper\_title’, ‘report-paper\_series’, ‘report-paper\_content’, ‘standard\_title’, ‘standard\_series’, ‘standard\_content’, ‘prepublication’}.
> 
> - Element ‘{http www crossref org/xschema/1.1}crossref’: No matching global element declaration available, but demanded by the strict wildcard.

Validating the results of the same DOI but with output format `unixref` (I had to fix the links in the `schemaLocation`s of the `xsd:import` tags), I get the error:

> - Element ‘doi\_records’: No matching global declaration available for the validation root.

I’ve also tried using the python `xmlschema` library to parse the output, but I get the same validation errors (`grant` is not valid, no `doi_records`).

---

<div class="post-metadata">

**Author:** ![ialarmedalien](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@ialarmedalien](https://community.crossref.org/u/ialarmedalien)\
**Post date:** [3 August 2022 14:16 UTC](https://community.crossref.org/t/xml-api-results-do-not-validate-against-the-schema/2858/2 "2022-08-03T14:16:35Z")

</div>

Re: the `unixsd` format query: if I fix the missing `grant` in the `type` field, validation fails due to numerous references to URLs containing `www`.`crossref`.`org/xschema/` which return 404s.

---

<div class="post-metadata">

**Author:** ![ialarmedalien](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@ialarmedalien](https://community.crossref.org/u/ialarmedalien)\
**Post date:** [3 August 2022 15:36 UTC](https://community.crossref.org/t/xml-api-results-do-not-validate-against-the-schema/2858/3 "2022-08-03T15:36:29Z")

</div>

Some background info on my use case may be helpful here.

I want to build a robust parser for CrossRef data and remap CrossRef fields to the schema that we use locally. For DataCite, I can autogenerate a set of models for their citation using the XSD and a python library. I can’t do that for CrossRef because there are circular references in the MathML XSD files that break the python library. Another option is to use the XSDs to parse the XML output from the CrossRef API. However, if the XML output does not match the XSDs, this method won’t work as the library will throw validation errors.

I asked about the schema for the JSON endpoints in another request. If there is somewhere in one of the crossref codebases where I can look to deduce the schema of the JSON output, I am happy to do that. I’m not particularly tied to JSON or XML, I just want to be able to build a parser and translator that can reliably convert the output from the CrossRef API to fit the local schema. Any suggestions?

Thanks!

---

<div class="post-metadata">

**Author:** ![ifarley](https://sea2.discourse-cdn.com/flex020/user_avatar/community.crossref.org/ifarley/32/44_2.png) [@ifarley](https://community.crossref.org/u/ifarley)\
**Post date:** [4 August 2022 17:15 UTC](https://community.crossref.org/t/xml-api-results-do-not-validate-against-the-schema/2858/5 "2022-08-04T17:15:45Z")

</div>

Hi @ialarmedalien ,

You’ll need to add the Grant ID Schema 0.1.1 as well. It is available here: [https://www.crossref.org/schemas/grant\_id0.1.1.xsd](https://www.crossref.org/schemas/grant_id0.1.1.xsd). This might also prove to be helpful: [XSD schema quick reference - Crossref](https://www.crossref.org/documentation/schema-library/xsd-schema-quick-reference/).

We’ve moved our documentation to [swagger,](https://api.crossref.org/swagger-ui/index.html) but this might also be helpful: [https://github.com/CrossRef/rest-api-doc](https://github.com/CrossRef/rest-api-doc).

My best,  
Isaac

---

<div class="post-metadata">

**Author:** ![ialarmedalien](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@ialarmedalien](https://community.crossref.org/u/ialarmedalien)\
**Post date:** [4 August 2022 22:18 UTC](https://community.crossref.org/t/xml-api-results-do-not-validate-against-the-schema/2858/6 "2022-08-04T22:18:13Z")

</div>

Hi @ifarley ,

> [@ifarley](#):
>
> You’ll need to add the Grant ID Schema 0.1.1 as well. It is available here: `https://www.crossref.org/schemas/grant_id0.1.1.xsd`. This might also prove to be helpful: XSD schema quick reference - Crossref `https://www.crossref.org/documentation/schema-library/xsd-schema-quick-reference/`.

I’ve been consulting the documentation heavily, which is why I’m finding it frustrating that results from the various APIs don’t match with what the documentation and published schemas say that they should be.

> [@ifarley](#):
>
> We’ve moved our documentation to swagger, but this might also be helpful: github com/CrossRef/rest-api-doc.

Thanks – that was useful, and I was able to put together a skeletal JSONschema version of the REST API output.

Unfortunately, the schema described in that documentation is not correct if the work being retrieved describes a grant, which is what I asked about in this other post:

> [@JSON schema for content negotiation](https://community.crossref.org/t/json-schema-for-content-negotiation/2844/6):
>
> Thus my question is: how can a parser know, without human intervention, what schema the REST API output from `/works/{doi}` is using?
