Skip to content

Commit 9821220

Browse files
committed
Fix #255: Metmorph emits null as entity name
1 parent cbc995f commit 9821220

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

src/main/resources/schemata/metamorph.xsd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,10 @@
416416
<element ref="tns:entity" />
417417
<element ref="tns:call-macro" />
418418
</choice>
419-
<attribute name="name" type="string" use="optional">
419+
<attribute name="name" type="string" use="optional" default="">
420420
<annotation>
421421
<documentation>Name of the entity. If not given the entity must
422-
have an entity-name element.</documentation>
422+
have an entity-name element otherwise an empty name is emitted</documentation>
423423
</annotation>
424424
</attribute>
425425
<attribute name="reset" type="boolean" use="optional"

src/test/java/org/culturegraph/mf/morph/collectors/EntityTest.xml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@
370370
</cgxml:cgxml>
371371
</result>
372372
</test-case>
373-
373+
374374
<test-case name="shouldResetNameToNameAttribute">
375375
<input type="text/x-cg+xml">
376376
<cgxml:cgxml version="1.0">
@@ -417,5 +417,39 @@
417417
</cgxml:cgxml>
418418
</result>
419419
</test-case>
420-
420+
421+
<test-case name="should emit empty string if entity name is not set">
422+
<input type="text/x-cg+xml">
423+
<cgxml:cgxml version="1.0">
424+
<cgxml:records>
425+
<cgxml:record id="1">
426+
<cgxml:literal name="in" value="a" />
427+
</cgxml:record>
428+
</cgxml:records>
429+
</cgxml:cgxml>
430+
</input>
431+
432+
<transformation type="text/x-metamorph+xml">
433+
<mm:metamorph version="1">
434+
<mm:rules>
435+
<mm:entity>
436+
<mm:data source="in" name="out" />
437+
</mm:entity>
438+
</mm:rules>
439+
</mm:metamorph>
440+
</transformation>
441+
442+
<result type="text/x-cg+xml">
443+
<cgxml:cgxml version="1.0">
444+
<cgxml:records>
445+
<cgxml:record id="1">
446+
<cgxml:entity name="">
447+
<cgxml:literal name="out" value="a" />
448+
</cgxml:entity>
449+
</cgxml:record>
450+
</cgxml:records>
451+
</cgxml:cgxml>
452+
</result>
453+
</test-case>
454+
421455
</metamorph-test>

0 commit comments

Comments
 (0)