概要
JPCOARスキーマでは、XMLスキーマ定義を以下のリポジトリで公開してくださっています。スキーマの作成およびデータの公開を行っていただき、ありがとうございます。
https://github.com/JPCOAR/schema
本記事では、上記のスキーマを使ったxmlファイルのバリデーションを試してみたので、その備忘録です。(今回のようなバリデーションは初めてのため、不正確な用語や情報を含む可能性があります。申し訳ありません。)
Google Colabのノートブックも用意しました。
準備
リポジトリのクローン
ライブラリのインストール
xsdファイルのロード(v1)
v1を試す
OKな例
NGな例
dc:typeの後にjpcoar:subjectを置くことによるエラー?
XsdValidationErrorWithInfo: /content/ng.xml: line 9 column 41: cvc-complex-type.2.4.a: Invalid content was found starting with element ‘{"https://github.com/JPCOAR/schema/blob/master/1.0/":subject}’. One of ‘{"https://schema.datacite.org/meta/kernel-4/":version, “http://namespace.openaire.eu/schema/oaire/":version, “https://github.com/JPCOAR/schema/blob/master/1.0/":identifier, “https://github.com/JPCOAR/schema/blob/master/1.0/":identifierRegistration, “https://github.com/JPCOAR/schema/blob/master/1.0/":relation, “http://purl.org/dc/terms/":temporal, “https://schema.datacite.org/meta/kernel-4/":geoLocation, “https://github.com/JPCOAR/schema/blob/master/1.0/":fundingReference, “https://github.com/JPCOAR/schema/blob/master/1.0/":sourceIdentifier, “https://github.com/JPCOAR/schema/blob/master/1.0/":sourceTitle, “https://github.com/JPCOAR/schema/blob/master/1.0/":volume, “https://github.com/JPCOAR/schema/blob/master/1.0/":issue, “https://github.com/JPCOAR/schema/blob/master/1.0/":numPages, “https://github.com/JPCOAR/schema/blob/master/1.0/":pageStart, “https://github.com/JPCOAR/schema/blob/master/1.0/":pageEnd, “http://ndl.go.jp/dcndl/terms/":dissertationNumber, “http://ndl.go.jp/dcndl/terms/":degreeName, “http://ndl.go.jp/dcndl/terms/":dateGranted, “https://github.com/JPCOAR/schema/blob/master/1.0/":degreeGrantor, “https://github.com/JPCOAR/schema/blob/master/1.0/":conference, “https://github.com/JPCOAR/schema/blob/master/1.0/":file}’ is expected.
修正
jpcoar:subjectの後にdc:typeを置いてみる
まとめ
エラーメッセージに基づき、xmlファイルを修正することができました。
Google Colabのノートブックでは、JPCOARスキーマVersion 2.0を対象としたバリデーション例も紹介しています。
不正確な内容を含んでいる可能性もありますが、xmlファイルのバリデーションの参考になりましたらい幸いです。