Skip to content

Commit b805f06

Browse files
committed
test for parsing of XML that is not possible to trasnform
1 parent 490c198 commit b805f06

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

spec/fixtures/_10.23650.xml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4/metadata.xsd">
3+
<!--doi标识符-->
4+
<identifier xmlns="http://datacite.org/schema/kernel-4" identifierType="DOI">10.23650/DATA.G.2018.P1</identifier>
5+
<!--doi指向的URL信息,name资源出版商名称,language为链接所指向资源语言,参看《ISO-639-2》-->
6+
<!--可以定义多个资源链接地址,例如中文版地址,英文版地址,一个DOI可以被解析到多个地址-->
7+
<creators xmlns="http://datacite.org/schema/kernel-4">
8+
<creator>
9+
<!--作者名称[必填]-->
10+
<creatorName>马洪云;李成柱;张俊</creatorName>
11+
<givenName/>
12+
<familyName/>
13+
<affiliation>干旱半干旱区地下水与生态重点实验室西安地质调查中心</affiliation>
14+
</creator>
15+
</creators>
16+
<titles xmlns="http://datacite.org/schema/kernel-4">
17+
<!--资源的标题[必填] titleType可参照:https://schema.datacite.org/meta/kernel-4.0/include/datacite-titleType-v4.xsd -->
18+
<title xml:lang="en-us">鄂尔多斯盆地地下水无机指标数据集(2014-2015年度)</title>
19+
<title xml:lang="en-us" titleType="TranslatedTitle">Inorganic Indicator Dataset for Groundwater in Ordos Basin (2014-2015)</title>
20+
</titles>
21+
<!--出版者[必填]-->
22+
<publisher xmlns="http://datacite.org/schema/kernel-4">全国地质资料馆</publisher>
23+
<!--出版年[必填] 如:2014-->
24+
<publicationYear xmlns="http://datacite.org/schema/kernel-4">2018</publicationYear>
25+
<!--关键词[必填]-->
26+
<subjects xmlns="http://datacite.org/schema/kernel-4">
27+
<subject xml:lang="en-us" schemeURI="" subjectScheme="">鄂尔多斯盆地;地下水;地球化学;无机指标;数据集</subject>
28+
</subjects>
29+
<!--基金会节点可以删除,如果不删除,以下内容必须填写-->
30+
<contributors xmlns="http://datacite.org/schema/kernel-4">
31+
<!--贡献者[必填] 贡献者类型必须为以下其中一个:ContactPerson, DataCollector, DataCurator, DataManager, Distributor, Editor, HostingInstitution, Other, Producer, ProjectLeader, ProjectManager, ProjectMember, RegistrationAgency, RegistrationAuthority, RelatedPerson, ResearchGroup, RightsHolder, Researcher, Sponsor, Supervisor, WorkPackageLeader-->
32+
<contributor contributorType="ContactPerson">
33+
<contributorName>马洪云</contributorName>
34+
<nameIdentifier schemeURI="" nameIdentifierScheme=""/>
35+
<affiliation>中国地质调查局发展研究中心</affiliation>
36+
</contributor>
37+
</contributors>
38+
<dates xmlns="http://datacite.org/schema/kernel-4">
39+
<!--时间[必填] 时间格式:2014-01-01 时间类型必须为以下其中一个:Accepted, Available, Collected, Copyrighted, Created, Issued, Submitted, Updated, Valid-->
40+
<date dateType="Accepted">2018-01-26</date>
41+
</dates>
42+
<!--语言[必填] 请参照 ISO 639-1 语言代码-->
43+
<language xmlns="http://datacite.org/schema/kernel-4">chi</language>
44+
<!--资源类型[必填] 资源类型必须为以下其中一个:Audiovisual, Collection, Dataset, Event, Image, InteractiveResource, Model, PhysicalObject, Service, Software, Sound, Text, Workflow, Other-->
45+
<resourceType xmlns="http://datacite.org/schema/kernel-4" resourceTypeGeneral="Dataset">Geochemistry</resourceType>
46+
<alternateIdentifiers xmlns="http://datacite.org/schema/kernel-4">
47+
<alternateIdentifier alternateIdentifierType=""/>
48+
</alternateIdentifiers>
49+
<relatedIdentifiers xmlns="http://datacite.org/schema/kernel-4">
50+
<!--关联标识-->
51+
<!--关联标识符类型必须为以下其中一个:ARK, arXiv, bibcode, DOI, EAN13, EISSN, Handle, IGSN, ISBN, ISSN, ISTC, LISSN, LSID, PMID, PURL, UPC, URL, URN-->
52+
<!--关联类型必须为以下其中一个:IsCitedBy, Cites, IsSupplementTo, IsSupplementedBy, IsContinuedBy, Continues, IsNewVersionOf, IsPreviousVersionOf, IsPartOf, HasPart, IsReferencedBy, References, IsDocumentedBy, Documents, IsCompiledBy, Compiles, IsVariantFormOf, IsOriginalFormOf, IsIdenticalTo, HasMetadata, IsMetadataFor, Reviews, IsReviewedBy, IsDerivedFrom, IsSourceOf-->
53+
<relatedIdentifier relatedIdentifierType="ARK" relationType="IsCitedBy" relatedMetadataScheme="" schemeURI=""/>
54+
</relatedIdentifiers>
55+
<sizes xmlns="http://datacite.org/schema/kernel-4">
56+
<!--数据大小-->
57+
<size>220 kB</size>
58+
</sizes>
59+
<formats xmlns="http://datacite.org/schema/kernel-4">
60+
<!--数据格式-->
61+
<format>excel</format>
62+
</formats>
63+
<!--数据版本-->
64+
<version xmlns="http://datacite.org/schema/kernel-4">1.0</version>
65+
<rightsList xmlns="http://datacite.org/schema/kernel-4">
66+
<!--版权申明-->
67+
<rights rightsURI="http://dcc.ngac.org.cn/home/dataauth.htm">版权信息详见网站</rights>
68+
</rightsList>
69+
<descriptions xmlns="http://datacite.org/schema/kernel-4">
70+
<!--摘要[必填] 摘要类型必须为以下其中一个:Abstract, Methods, SeriesInformation, TableOfContents, TechnicalInfo, Other-->
71+
<description xml:lang="en-us" descriptionType="Abstract">本数据集包含了2014年、2015年两年内在鄂尔多斯盆地采集的742个地下水样品的位置信息、取样层位信息及35项无机地球化学成分测试结果信息。采样过程规范,测试结果均由合格实验室测试完成,数据质量可靠。可以真实反映该时段鄂尔多斯盆地地下水质量状况,为研究鄂尔多斯盆地地下水循环演化提供地球化学指标参考。</description>
72+
</descriptions>
73+
<!--位置节点可以删除,如果不删除,以下内容必须是数字-->
74+
</resource>

spec/kernel-4/user_example_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'spec_helper'
2+
3+
describe "full example" do
4+
let(:doc) { Dir.chdir(RSPEC_ROOT) {Nokogiri::XML(File.read("fixtures/_10.23650.xml")) { |c| c.strict }}}
5+
let(:root) { File.join(File.dirname(__FILE__), '../../source/meta/kernel-4') }
6+
let(:xsd) { Dir.chdir(root) { Nokogiri::XML::Schema(File.read("metadata.xsd")) }}
7+
8+
it 'validates' do
9+
expect(doc).to pass_validation(xsd)
10+
end
11+
end

spec/spec_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
RSpec.configure do |config|
88
config.order = :random
99
config.include RSpec::XSD
10+
RSPEC_ROOT = File.dirname __FILE__
1011
end

0 commit comments

Comments
 (0)