Skip to content

Commit cbaf9d3

Browse files
committed
Add new FileMap options to Metamorph schema. (#471)
1 parent 995e069 commit cbaf9d3

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

metamorph/src/main/resources/schemata/metamorph.xsd

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,37 @@
629629
The default separator is the tabulator. </documentation>
630630
</annotation>
631631
</attribute>
632+
<attribute name="keyColumn" use="optional" default="0">
633+
<annotation>
634+
<documentation>Sets the key column (0-based).</documentation>
635+
</annotation>
636+
<simpleType>
637+
<restriction base="int">
638+
<minInclusive value="0" />
639+
</restriction>
640+
</simpleType>
641+
</attribute>
642+
<attribute name="valueColumn" use="optional" default="1">
643+
<annotation>
644+
<documentation>Sets the value column (0-based).</documentation>
645+
</annotation>
646+
<simpleType>
647+
<restriction base="int">
648+
<minInclusive value="0" />
649+
</restriction>
650+
</simpleType>
651+
</attribute>
652+
<attribute name="expectedColumns" use="optional" default="0">
653+
<annotation>
654+
<documentation>Sets number of expected columns; set to -1 to disable
655+
column check.</documentation>
656+
</annotation>
657+
<simpleType>
658+
<restriction base="int">
659+
<minInclusive value="-1" />
660+
</restriction>
661+
</simpleType>
662+
</attribute>
632663
<attribute ref="xml:base" />
633664
</complexType>
634665
</element>

metamorph/src/test/java/org/metafacture/metamorph/maps/FileMapTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,24 @@ public void shouldLookupValuesInFileBasedMap() {
7272
);
7373
}
7474

75+
@Test
76+
public void shouldLookupValuesInFileBasedMapWithColumnOptions() {
77+
assertMorph(receiver, buildMorph("lookup in", "keyColumn=\"1\" valueColumn=\"0\" expectedColumns=\"2\""),
78+
i -> {
79+
i.startRecord("1");
80+
i.literal("1", "Germany");
81+
i.literal("1", "Fiji");
82+
i.endRecord();
83+
},
84+
o -> {
85+
o.get().startRecord("1");
86+
o.get().literal("1", "gw");
87+
o.get().literal("1", "fj");
88+
o.get().endRecord();
89+
}
90+
);
91+
}
92+
7593
@Test
7694
public void shouldWhitelistValuesInFileBasedMap() {
7795
assertMorph(receiver, buildMorph("whitelist map", ""),

0 commit comments

Comments
 (0)