Ignore negative level structures in DeReKo#structure.xml

Change-Id: I93a4c13c919c49092edee00a7f0c3d50dbc9a1fe
diff --git a/Changes b/Changes
index 2adee64..7971f0b 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
-0.42 2020-11-03
+0.42 2021-02-16
         - Replaced Log4perl with Log::Any.
+        - Ignore level < 0 structures in DeReKo, but support
+          them for base annotations.
 
 0.41 2020-08-10
         - Added support for RWK annotations.
diff --git a/lib/KorAP/XML/Annotation/DeReKo/Structure.pm b/lib/KorAP/XML/Annotation/DeReKo/Structure.pm
index 2143a1d..4da384e 100644
--- a/lib/KorAP/XML/Annotation/DeReKo/Structure.pm
+++ b/lib/KorAP/XML/Annotation/DeReKo/Structure.pm
@@ -46,10 +46,15 @@
         return;
       };
 
-      # Add structure
-      my $mt = $mtt->add_span('<>:dereko/s:' . $name, $span);
-      # $mt->set_p_start($p_start);
-      $mt->set_pti($span->get_milestone ? 65 : 64);
+      # Create MT
+      my $mt = KorAP::XML::Index::MultiTerm->new(
+        '<>:dereko/s:' . $name,        # Term
+        $span->get_o_start,            # o_start
+        $span->get_o_end,              # o_end
+        undef,                         # p_start
+        $span->get_p_end,              # p_end
+        $span->get_milestone ? 65 : 64 # pti
+      );
 
       my $level = $span->get_hash->{'-l'};
       if ($level || $tui) {
@@ -59,6 +64,11 @@
         $mt->set_payload($pl);
       };
 
+      # Add structure only if level is not negative
+      if (!$level || $level >= 0) {
+        $mtt->add_blessed($mt);
+      };
+
       # Use sentence and paragraph elements for base
       if ($as_base && ($name eq 's' || $name eq 'p' || $name eq 'pb')) {
 
diff --git a/script/korapxml2krill b/script/korapxml2krill
index ab68d96..5e020df 100644
--- a/script/korapxml2krill
+++ b/script/korapxml2krill
@@ -1143,7 +1143,8 @@
 
 Define the layer for base paragraphs.
 If given, this will be used instead of using C<Base#Paragraphs>.
-Currently C<DeReKo#Structure> is the only additional layer supported.
+Currently C<DeReKo#Structure> and C<DGD#Structure> are the only additional
+layer supported.
 
  Defaults to unset.
 
diff --git a/t/real/corpus/REI/RBP/00007/base/tokens.xml b/t/real/corpus/REI/RBP/00007/base/tokens.xml
new file mode 100644
index 0000000..8f5a563
--- /dev/null
+++ b/t/real/corpus/REI/RBP/00007/base/tokens.xml
@@ -0,0 +1,489 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-model href="span.rng"
+            type="application/xml"
+            schematypens="http://relaxng.org/ns/structure/1.0"?>
+<layer docid="REI_RBP.00007"
+       xmlns="http://ids-mannheim.de/ns/KorAP"
+       version="KorAP-0.4">
+  <spanList>
+    <span id="t_0" from="0" to="9" />
+    <span id="t_1" from="10" to="13" />
+    <span id="t_2" from="14" to="29" />
+    <span id="t_3" from="30" to="37" />
+    <span id="t_4" from="38" to="41" />
+    <span id="t_5" from="42" to="52" />
+    <span id="t_6" from="53" to="56" />
+    <span id="t_7" from="57" to="62" />
+    <span id="t_8" from="63" to="73" />
+    <span id="t_9" from="73" to="74" />
+    <span id="t_10" from="75" to="82" />
+    <span id="t_11" from="83" to="86" />
+    <span id="t_12" from="87" to="94" />
+    <span id="t_13" from="95" to="102" />
+    <span id="t_14" from="103" to="106" />
+    <span id="t_15" from="107" to="112" />
+    <span id="t_16" from="113" to="118" />
+    <span id="t_17" from="119" to="121" />
+    <span id="t_18" from="122" to="133" />
+    <span id="t_19" from="134" to="140" />
+    <span id="t_20" from="141" to="143" />
+    <span id="t_21" from="144" to="146" />
+    <span id="t_22" from="147" to="150" />
+    <span id="t_23" from="151" to="154" />
+    <span id="t_24" from="155" to="164" />
+    <span id="t_25" from="164" to="165" />
+    <span id="t_26" from="166" to="171" />
+    <span id="t_27" from="172" to="176" />
+    <span id="t_28" from="177" to="182" />
+    <span id="t_29" from="183" to="188" />
+    <span id="t_30" from="189" to="191" />
+    <span id="t_31" from="192" to="196" />
+    <span id="t_32" from="196" to="197" />
+    <span id="t_33" from="198" to="201" />
+    <span id="t_34" from="202" to="205" />
+    <span id="t_35" from="206" to="210" />
+    <span id="t_36" from="211" to="219" />
+    <span id="t_37" from="220" to="225" />
+    <span id="t_38" from="226" to="228" />
+    <span id="t_39" from="229" to="233" />
+    <span id="t_40" from="234" to="236" />
+    <span id="t_41" from="237" to="242" />
+    <span id="t_42" from="242" to="243" />
+    <span id="t_43" from="244" to="251" />
+    <span id="t_44" from="252" to="254" />
+    <span id="t_45" from="255" to="259" />
+    <span id="t_46" from="260" to="265" />
+    <span id="t_47" from="266" to="279" />
+    <span id="t_48" from="279" to="280" />
+    <span id="t_49" from="281" to="284" />
+    <span id="t_50" from="285" to="290" />
+    <span id="t_51" from="291" to="302" />
+    <span id="t_52" from="303" to="319" />
+    <span id="t_53" from="320" to="323" />
+    <span id="t_54" from="324" to="327" />
+    <span id="t_55" from="328" to="338" />
+    <span id="t_56" from="339" to="346" />
+    <span id="t_57" from="347" to="352" />
+    <span id="t_58" from="352" to="353" />
+    <span id="t_59" from="354" to="357" />
+    <span id="t_60" from="358" to="362" />
+    <span id="t_61" from="363" to="367" />
+    <span id="t_62" from="368" to="374" />
+    <span id="t_63" from="374" to="375" />
+    <span id="t_64" from="376" to="379" />
+    <span id="t_65" from="380" to="389" />
+    <span id="t_66" from="390" to="392" />
+    <span id="t_67" from="393" to="400" />
+    <span id="t_68" from="401" to="405" />
+    <span id="t_69" from="406" to="409" />
+    <span id="t_70" from="409" to="410" />
+    <span id="t_71" from="411" to="414" />
+    <span id="t_72" from="415" to="426" />
+    <span id="t_73" from="427" to="435" />
+    <span id="t_74" from="436" to="438" />
+    <span id="t_75" from="439" to="446" />
+    <span id="t_76" from="446" to="447" />
+    <span id="t_77" from="448" to="452" />
+    <span id="t_78" from="453" to="458" />
+    <span id="t_79" from="459" to="462" />
+    <span id="t_80" from="463" to="472" />
+    <span id="t_81" from="473" to="484" />
+    <span id="t_82" from="485" to="491" />
+    <span id="t_83" from="492" to="501" />
+    <span id="t_84" from="501" to="502" />
+    <span id="t_85" from="503" to="507" />
+    <span id="t_86" from="508" to="510" />
+    <span id="t_87" from="511" to="514" />
+    <span id="t_88" from="515" to="524" />
+    <span id="t_89" from="525" to="528" />
+    <span id="t_90" from="528" to="529" />
+    <span id="t_91" from="530" to="532" />
+    <span id="t_92" from="533" to="542" />
+    <span id="t_93" from="542" to="543" />
+    <span id="t_94" from="544" to="548" />
+    <span id="t_95" from="549" to="554" />
+    <span id="t_96" from="555" to="558" />
+    <span id="t_97" from="559" to="562" />
+    <span id="t_98" from="563" to="571" />
+    <span id="t_99" from="572" to="584" />
+    <span id="t_100" from="585" to="591" />
+    <span id="t_101" from="591" to="592" />
+    <span id="t_102" from="593" to="598" />
+    <span id="t_103" from="599" to="608" />
+    <span id="t_104" from="609" to="612" />
+    <span id="t_105" from="613" to="620" />
+    <span id="t_106" from="621" to="625" />
+    <span id="t_107" from="626" to="629" />
+    <span id="t_108" from="630" to="633" />
+    <span id="t_109" from="634" to="637" />
+    <span id="t_110" from="638" to="648" />
+    <span id="t_111" from="649" to="653" />
+    <span id="t_112" from="653" to="654" />
+    <span id="t_113" from="655" to="657" />
+    <span id="t_114" from="658" to="661" />
+    <span id="t_115" from="662" to="672" />
+    <span id="t_116" from="673" to="676" />
+    <span id="t_117" from="677" to="682" />
+    <span id="t_118" from="683" to="691" />
+    <span id="t_119" from="692" to="695" />
+    <span id="t_120" from="696" to="704" />
+    <span id="t_121" from="704" to="705" />
+    <span id="t_122" from="706" to="708" />
+    <span id="t_123" from="709" to="712" />
+    <span id="t_124" from="713" to="715" />
+    <span id="t_125" from="716" to="721" />
+    <span id="t_126" from="722" to="726" />
+    <span id="t_127" from="726" to="727" />
+    <span id="t_128" from="728" to="731" />
+    <span id="t_129" from="732" to="737" />
+    <span id="t_130" from="738" to="741" />
+    <span id="t_131" from="742" to="747" />
+    <span id="t_132" from="748" to="751" />
+    <span id="t_133" from="752" to="761" />
+    <span id="t_134" from="762" to="764" />
+    <span id="t_135" from="765" to="768" />
+    <span id="t_136" from="769" to="788" />
+    <span id="t_137" from="789" to="792" />
+    <span id="t_138" from="793" to="801" />
+    <span id="t_139" from="802" to="805" />
+    <span id="t_140" from="806" to="814" />
+    <span id="t_141" from="814" to="815" />
+    <span id="t_142" from="816" to="819" />
+    <span id="t_143" from="820" to="822" />
+    <span id="t_144" from="823" to="826" />
+    <span id="t_145" from="827" to="839" />
+    <span id="t_146" from="840" to="849" />
+    <span id="t_147" from="850" to="855" />
+    <span id="t_148" from="855" to="856" />
+    <span id="t_149" from="857" to="859" />
+    <span id="t_150" from="860" to="863" />
+    <span id="t_151" from="864" to="870" />
+    <span id="t_152" from="871" to="874" />
+    <span id="t_153" from="875" to="882" />
+    <span id="t_154" from="882" to="883" />
+    <span id="t_155" from="884" to="887" />
+    <span id="t_156" from="888" to="893" />
+    <span id="t_157" from="893" to="894" />
+    <span id="t_158" from="895" to="898" />
+    <span id="t_159" from="899" to="902" />
+    <span id="t_160" from="903" to="912" />
+    <span id="t_161" from="913" to="922" />
+    <span id="t_162" from="922" to="923" />
+    <span id="t_163" from="924" to="927" />
+    <span id="t_164" from="928" to="933" />
+    <span id="t_165" from="934" to="936" />
+    <span id="t_166" from="937" to="942" />
+    <span id="t_167" from="943" to="946" />
+    <span id="t_168" from="947" to="951" />
+    <span id="t_169" from="952" to="955" />
+    <span id="t_170" from="956" to="968" />
+    <span id="t_171" from="969" to="972" />
+    <span id="t_172" from="973" to="977" />
+    <span id="t_173" from="978" to="983" />
+    <span id="t_174" from="984" to="1000" />
+    <span id="t_175" from="1001" to="1004" />
+    <span id="t_176" from="1005" to="1017" />
+    <span id="t_177" from="1017" to="1018" />
+    <span id="t_178" from="1019" to="1023" />
+    <span id="t_179" from="1023" to="1024" />
+    <span id="t_180" from="1025" to="1029" />
+    <span id="t_181" from="1030" to="1033" />
+    <span id="t_182" from="1034" to="1037" />
+    <span id="t_183" from="1038" to="1040" />
+    <span id="t_184" from="1041" to="1051" />
+    <span id="t_185" from="1052" to="1056" />
+    <span id="t_186" from="1056" to="1057" />
+    <span id="t_187" from="1058" to="1063" />
+    <span id="t_188" from="1064" to="1069" />
+    <span id="t_189" from="1069" to="1070" />
+    <span id="t_190" from="1071" to="1073" />
+    <span id="t_191" from="1074" to="1078" />
+    <span id="t_192" from="1079" to="1081" />
+    <span id="t_193" from="1082" to="1085" />
+    <span id="t_194" from="1086" to="1092" />
+    <span id="t_195" from="1093" to="1096" />
+    <span id="t_196" from="1097" to="1106" />
+    <span id="t_197" from="1106" to="1107" />
+    <span id="t_198" from="1108" to="1110" />
+    <span id="t_199" from="1111" to="1121" />
+    <span id="t_200" from="1121" to="1122" />
+    <span id="t_201" from="1123" to="1126" />
+    <span id="t_202" from="1127" to="1129" />
+    <span id="t_203" from="1130" to="1133" />
+    <span id="t_204" from="1134" to="1138" />
+    <span id="t_205" from="1138" to="1139" />
+    <span id="t_206" from="1140" to="1143" />
+    <span id="t_207" from="1144" to="1148" />
+    <span id="t_208" from="1149" to="1152" />
+    <span id="t_209" from="1153" to="1165" />
+    <span id="t_210" from="1166" to="1171" />
+    <span id="t_211" from="1172" to="1175" />
+    <span id="t_212" from="1176" to="1180" />
+    <span id="t_213" from="1181" to="1184" />
+    <span id="t_214" from="1185" to="1188" />
+    <span id="t_215" from="1189" to="1193" />
+    <span id="t_216" from="1194" to="1200" />
+    <span id="t_217" from="1200" to="1201" />
+    <span id="t_218" from="1202" to="1205" />
+    <span id="t_219" from="1206" to="1212" />
+    <span id="t_220" from="1213" to="1216" />
+    <span id="t_221" from="1217" to="1220" />
+    <span id="t_222" from="1221" to="1234" />
+    <span id="t_223" from="1235" to="1238" />
+    <span id="t_224" from="1239" to="1247" />
+    <span id="t_225" from="1248" to="1254" />
+    <span id="t_226" from="1255" to="1261" />
+    <span id="t_227" from="1261" to="1262" />
+    <span id="t_228" from="1263" to="1266" />
+    <span id="t_229" from="1267" to="1275" />
+    <span id="t_230" from="1276" to="1279" />
+    <span id="t_231" from="1280" to="1287" />
+    <span id="t_232" from="1288" to="1291" />
+    <span id="t_233" from="1292" to="1295" />
+    <span id="t_234" from="1296" to="1304" />
+    <span id="t_235" from="1305" to="1308" />
+    <span id="t_236" from="1309" to="1315" />
+    <span id="t_237" from="1315" to="1316" />
+    <span id="t_238" from="1317" to="1320" />
+    <span id="t_239" from="1321" to="1323" />
+    <span id="t_240" from="1324" to="1327" />
+    <span id="t_241" from="1328" to="1331" />
+    <span id="t_242" from="1332" to="1345" />
+    <span id="t_243" from="1346" to="1356" />
+    <span id="t_244" from="1357" to="1360" />
+    <span id="t_245" from="1361" to="1369" />
+    <span id="t_246" from="1370" to="1384" />
+    <span id="t_247" from="1385" to="1389" />
+    <span id="t_248" from="1389" to="1390" />
+    <span id="t_249" from="1391" to="1396" />
+    <span id="t_250" from="1397" to="1402" />
+    <span id="t_251" from="1403" to="1407" />
+    <span id="t_252" from="1408" to="1421" />
+    <span id="t_253" from="1422" to="1426" />
+    <span id="t_254" from="1426" to="1427" />
+    <span id="t_255" from="1428" to="1431" />
+    <span id="t_256" from="1432" to="1438" />
+    <span id="t_257" from="1438" to="1439" />
+    <span id="t_258" from="1440" to="1443" />
+    <span id="t_259" from="1444" to="1455" />
+    <span id="t_260" from="1456" to="1462" />
+    <span id="t_261" from="1463" to="1466" />
+    <span id="t_262" from="1467" to="1470" />
+    <span id="t_263" from="1471" to="1483" />
+    <span id="t_264" from="1484" to="1486" />
+    <span id="t_265" from="1487" to="1490" />
+    <span id="t_266" from="1491" to="1510" />
+    <span id="t_267" from="1511" to="1514" />
+    <span id="t_268" from="1515" to="1518" />
+    <span id="t_269" from="1519" to="1525" />
+    <span id="t_270" from="1525" to="1526" />
+    <span id="t_271" from="1527" to="1531" />
+    <span id="t_272" from="1532" to="1535" />
+    <span id="t_273" from="1536" to="1544" />
+    <span id="t_274" from="1545" to="1548" />
+    <span id="t_275" from="1549" to="1552" />
+    <span id="t_276" from="1553" to="1558" />
+    <span id="t_277" from="1559" to="1565" />
+    <span id="t_278" from="1566" to="1574" />
+    <span id="t_279" from="1574" to="1575" />
+    <span id="t_280" from="1576" to="1580" />
+    <span id="t_281" from="1581" to="1584" />
+    <span id="t_282" from="1585" to="1593" />
+    <span id="t_283" from="1594" to="1597" />
+    <span id="t_284" from="1598" to="1601" />
+    <span id="t_285" from="1602" to="1607" />
+    <span id="t_286" from="1608" to="1613" />
+    <span id="t_287" from="1613" to="1614" />
+    <span id="t_288" from="1615" to="1618" />
+    <span id="t_289" from="1619" to="1622" />
+    <span id="t_290" from="1623" to="1629" />
+    <span id="t_291" from="1630" to="1639" />
+    <span id="t_292" from="1640" to="1645" />
+    <span id="t_293" from="1645" to="1646" />
+    <span id="t_294" from="1647" to="1650" />
+    <span id="t_295" from="1651" to="1656" />
+    <span id="t_296" from="1657" to="1659" />
+    <span id="t_297" from="1660" to="1663" />
+    <span id="t_298" from="1664" to="1671" />
+    <span id="t_299" from="1672" to="1683" />
+    <span id="t_300" from="1684" to="1692" />
+    <span id="t_301" from="1692" to="1693" />
+    <span id="t_302" from="1694" to="1697" />
+    <span id="t_303" from="1698" to="1702" />
+    <span id="t_304" from="1703" to="1705" />
+    <span id="t_305" from="1706" to="1712" />
+    <span id="t_306" from="1713" to="1720" />
+    <span id="t_307" from="1721" to="1727" />
+    <span id="t_308" from="1728" to="1739" />
+    <span id="t_309" from="1739" to="1740" />
+    <span id="t_310" from="1741" to="1750" />
+    <span id="t_311" from="1750" to="1751" />
+    <span id="t_312" from="1752" to="1755" />
+    <span id="t_313" from="1756" to="1761" />
+    <span id="t_314" from="1762" to="1770" />
+    <span id="t_315" from="1770" to="1771" />
+    <span id="t_316" from="1772" to="1778" />
+    <span id="t_317" from="1779" to="1782" />
+    <span id="t_318" from="1783" to="1790" />
+    <span id="t_319" from="1790" to="1791" />
+    <span id="t_320" from="1792" to="1795" />
+    <span id="t_321" from="1796" to="1800" />
+    <span id="t_322" from="1801" to="1804" />
+    <span id="t_323" from="1805" to="1810" />
+    <span id="t_324" from="1811" to="1818" />
+    <span id="t_325" from="1819" to="1824" />
+    <span id="t_326" from="1824" to="1825" />
+    <span id="t_327" from="1826" to="1829" />
+    <span id="t_328" from="1830" to="1833" />
+    <span id="t_329" from="1834" to="1838" />
+    <span id="t_330" from="1839" to="1847" />
+    <span id="t_331" from="1848" to="1851" />
+    <span id="t_332" from="1852" to="1858" />
+    <span id="t_333" from="1859" to="1866" />
+    <span id="t_334" from="1866" to="1867" />
+    <span id="t_335" from="1868" to="1872" />
+    <span id="t_336" from="1873" to="1877" />
+    <span id="t_337" from="1878" to="1885" />
+    <span id="t_338" from="1886" to="1888" />
+    <span id="t_339" from="1889" to="1894" />
+    <span id="t_340" from="1895" to="1902" />
+    <span id="t_341" from="1903" to="1908" />
+    <span id="t_342" from="1908" to="1909" />
+    <span id="t_343" from="1910" to="1914" />
+    <span id="t_344" from="1915" to="1918" />
+    <span id="t_345" from="1919" to="1922" />
+    <span id="t_346" from="1923" to="1928" />
+    <span id="t_347" from="1929" to="1934" />
+    <span id="t_348" from="1935" to="1938" />
+    <span id="t_349" from="1939" to="1944" />
+    <span id="t_350" from="1945" to="1953" />
+    <span id="t_351" from="1954" to="1957" />
+    <span id="t_352" from="1958" to="1964" />
+    <span id="t_353" from="1965" to="1971" />
+    <span id="t_354" from="1972" to="1975" />
+    <span id="t_355" from="1976" to="1984" />
+    <span id="t_356" from="1985" to="1991" />
+    <span id="t_357" from="1991" to="1992" />
+    <span id="t_358" from="1993" to="1997" />
+    <span id="t_359" from="1998" to="2000" />
+    <span id="t_360" from="2001" to="2006" />
+    <span id="t_361" from="2007" to="2009" />
+    <span id="t_362" from="2010" to="2017" />
+    <span id="t_363" from="2018" to="2028" />
+    <span id="t_364" from="2029" to="2032" />
+    <span id="t_365" from="2033" to="2035" />
+    <span id="t_366" from="2036" to="2040" />
+    <span id="t_367" from="2041" to="2047" />
+    <span id="t_368" from="2048" to="2061" />
+    <span id="t_369" from="2062" to="2065" />
+    <span id="t_370" from="2066" to="2086" />
+    <span id="t_371" from="2087" to="2095" />
+    <span id="t_372" from="2096" to="2103" />
+    <span id="t_373" from="2104" to="2107" />
+    <span id="t_374" from="2108" to="2110" />
+    <span id="t_375" from="2111" to="2118" />
+    <span id="t_376" from="2118" to="2119" />
+    <span id="t_377" from="2120" to="2123" />
+    <span id="t_378" from="2124" to="2130" />
+    <span id="t_379" from="2131" to="2137" />
+    <span id="t_380" from="2138" to="2142" />
+    <span id="t_381" from="2143" to="2148" />
+    <span id="t_382" from="2149" to="2155" />
+    <span id="t_383" from="2156" to="2161" />
+    <span id="t_384" from="2161" to="2162" />
+    <span id="t_385" from="2163" to="2169" />
+    <span id="t_386" from="2170" to="2184" />
+    <span id="t_387" from="2185" to="2191" />
+    <span id="t_388" from="2192" to="2199" />
+    <span id="t_389" from="2199" to="2200" />
+    <span id="t_390" from="2201" to="2203" />
+    <span id="t_391" from="2204" to="2207" />
+    <span id="t_392" from="2208" to="2211" />
+    <span id="t_393" from="2212" to="2217" />
+    <span id="t_394" from="2218" to="2226" />
+    <span id="t_395" from="2227" to="2232" />
+    <span id="t_396" from="2232" to="2233" />
+    <span id="t_397" from="2234" to="2239" />
+    <span id="t_398" from="2240" to="2244" />
+    <span id="t_399" from="2245" to="2248" />
+    <span id="t_400" from="2249" to="2256" />
+    <span id="t_401" from="2256" to="2257" />
+    <span id="t_402" from="2258" to="2268" />
+    <span id="t_403" from="2269" to="2277" />
+    <span id="t_404" from="2277" to="2278" />
+    <span id="t_405" from="2279" to="2283" />
+    <span id="t_406" from="2284" to="2286" />
+    <span id="t_407" from="2287" to="2295" />
+    <span id="t_408" from="2296" to="2299" />
+    <span id="t_409" from="2300" to="2302" />
+    <span id="t_410" from="2303" to="2314" />
+    <span id="t_411" from="2314" to="2315" />
+    <span id="t_412" from="2316" to="2318" />
+    <span id="t_413" from="2319" to="2322" />
+    <span id="t_414" from="2323" to="2332" />
+    <span id="t_415" from="2333" to="2336" />
+    <span id="t_416" from="2337" to="2340" />
+    <span id="t_417" from="2341" to="2347" />
+    <span id="t_418" from="2348" to="2352" />
+    <span id="t_419" from="2353" to="2356" />
+    <span id="t_420" from="2357" to="2361" />
+    <span id="t_421" from="2362" to="2368" />
+    <span id="t_422" from="2368" to="2369" />
+    <span id="t_423" from="2370" to="2373" />
+    <span id="t_424" from="2374" to="2376" />
+    <span id="t_425" from="2377" to="2379" />
+    <span id="t_426" from="2380" to="2385" />
+    <span id="t_427" from="2386" to="2390" />
+    <span id="t_428" from="2391" to="2398" />
+    <span id="t_429" from="2399" to="2402" />
+    <span id="t_430" from="2402" to="2403" />
+    <span id="t_431" from="2404" to="2408" />
+    <span id="t_432" from="2409" to="2412" />
+    <span id="t_433" from="2413" to="2418" />
+    <span id="t_434" from="2419" to="2422" />
+    <span id="t_435" from="2423" to="2429" />
+    <span id="t_436" from="2430" to="2433" />
+    <span id="t_437" from="2434" to="2443" />
+    <span id="t_438" from="2444" to="2447" />
+    <span id="t_439" from="2448" to="2456" />
+    <span id="t_440" from="2456" to="2457" />
+    <span id="t_441" from="2458" to="2461" />
+    <span id="t_442" from="2462" to="2464" />
+    <span id="t_443" from="2465" to="2472" />
+    <span id="t_444" from="2473" to="2483" />
+    <span id="t_445" from="2484" to="2489" />
+    <span id="t_446" from="2489" to="2490" />
+    <span id="t_447" from="2491" to="2494" />
+    <span id="t_448" from="2495" to="2498" />
+    <span id="t_449" from="2499" to="2505" />
+    <span id="t_450" from="2506" to="2513" />
+    <span id="t_451" from="2514" to="2517" />
+    <span id="t_452" from="2518" to="2521" />
+    <span id="t_453" from="2521" to="2522" />
+    <span id="t_454" from="2523" to="2530" />
+    <span id="t_455" from="2531" to="2536" />
+    <span id="t_456" from="2537" to="2540" />
+    <span id="t_457" from="2541" to="2546" />
+    <span id="t_458" from="2547" to="2552" />
+    <span id="t_459" from="2553" to="2556" />
+    <span id="t_460" from="2557" to="2563" />
+    <span id="t_461" from="2564" to="2575" />
+    <span id="t_462" from="2576" to="2581" />
+    <span id="t_463" from="2581" to="2582" />
+    <span id="t_464" from="2583" to="2586" />
+    <span id="t_465" from="2587" to="2590" />
+    <span id="t_466" from="2591" to="2598" />
+    <span id="t_467" from="2599" to="2601" />
+    <span id="t_468" from="2602" to="2608" />
+    <span id="t_469" from="2609" to="2620" />
+    <span id="t_470" from="2621" to="2627" />
+    <span id="t_471" from="2628" to="2631" />
+    <span id="t_472" from="2632" to="2634" />
+    <span id="t_473" from="2635" to="2638" />
+    <span id="t_474" from="2639" to="2642" />
+    <span id="t_475" from="2643" to="2652" />
+    <span id="t_476" from="2653" to="2659" />
+    <span id="t_477" from="2660" to="2663" />
+    <span id="t_478" from="2663" to="2664" />
+  </spanList>
+</layer>
diff --git a/t/real/corpus/REI/RBP/00007/data.xml b/t/real/corpus/REI/RBP/00007/data.xml
new file mode 100644
index 0000000..d969f05
--- /dev/null
+++ b/t/real/corpus/REI/RBP/00007/data.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-model href="text.rng"
+            type="application/xml"
+            schematypens="http://relaxng.org/ns/structure/1.0"?>
+<raw_text docid="REI_RBP.00007"
+          xmlns="http://ids-mannheim.de/ns/KorAP">
+  <metadata file="metadata.xml" />
+  <text>Ansprache von Bundespräsident Richard von Weizsäcker bei einem Abendessen, gegeben von Königin Beatrix und Prinz Claus im Königlichen Palais Op de Dam Der Einladung, heute hier unter Ihnen zu sein, bin ich gern gefolgt- nicht um viel zu sagen, sondern um Dank dafür auszusprechen, daß diese Ausstellung zusammengestellt und uns zugänglich gemacht wurde. Man kann sich denken, wie schwierig es gewesen sein muß, die Ausstellung zustande zu bringen, denn unter den damaligen Bedingungen mußten Dokumente, wenn es sie überhaupt gab, ja verborgen, aber nicht für die Nachwelt bereitgelegt werden. Diese Dokumente aus Kreisau sind für uns von besonderem Wert. Es ist einerseits der weite Horizont der Gedanken, um die es dabei geht; man sieht die Weite des Horizonts an der Unterschiedlichkeit der Herkunft der Menschen, die an den Überlegungen beteiligt waren. Es ist sodann die Aufgabe, der Platz, den die Kreisauer einnehmen. Sie waren ja nicht die Hand der Verschwörung und auch nicht Kommandozentrale des Widerstandes, aber, wenn man das so ausdrücken darf, seine Seele. Es ging um die Fragen des Gewissens, um Reflektion, und um den Sinn, den Sinn des Widerstandes gegen das Böse und den Sinn dessen, was danach für das Zusammenleben der Menschen kommen sollte. Die Reinheit des Denkens und die Reinheit des Wesens, die in den uns überlieferten Dokumenten und Gedanken wiederzufinden sind, haben einen ganz einzigartigen Rang. Die Briefe, die geschrieben wurden aus den Gefängnissen an die Familienangehörigen und die Frauen, sind ein Ausdruck von der Kraft dieser Reinheit, auch ein Ausdruck von der Kraft derer, die die Briefe empfangen haben. Oft haben in den letzten Jahrzehnten Menschen, die sich am Aufbau unseres Landes beteiligten, empfunden, wie viele Menschen, gerade aus Kreisau, uns nach dem Krieg gefehlt haben. Der Weg wäre leichter und klarer gewesen, wenn ihre Stimmen zu hören gewesen wären, wenn sie mit ihrer Kraft und ihrem Gewissen uns hätten helfen und anleiten können. Wann je sonst in unserer Geschichte hat es eine solche Konzentration von sittlich-politischer Substanz gegeben wie in Kreisau? Wir müssen unsere Wege heute selber gehen, unsere Entscheidungen selbst treffen. Es ist für viele Menschen heute, zumal auch für jüngere, vielleicht schwerer, klar zu erkennen und zu beschreiben, wo die Antworten auf die Fragen nach dem Sinn liegen, als es in jener Zeit gewesen ist. Aber das Leben und Denken und Empfinden der Menschen, die in Kreisau versammelt waren, ist und bleibt Maßstab für uns. Deshalb haben wir allen Grund zur großen Dankbarkeit dafür, daß der Gedanke zu dieser Ausstellung gefaßt und in die Tat umgesetzt worden ist.</text>
+</raw_text>
\ No newline at end of file
diff --git a/t/real/corpus/REI/RBP/00007/header.xml b/t/real/corpus/REI/RBP/00007/header.xml
new file mode 100644
index 0000000..f774b55
--- /dev/null
+++ b/t/real/corpus/REI/RBP/00007/header.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-model href="header.rng"
+            type="application/xml"
+            schematypens="http://relaxng.org/ns/structure/1.0"?>
+<!DOCTYPE idsCorpus PUBLIC "-//IDS//DTD IDS-XCES 1.0//EN"
+          "http://corpora.ids-mannheim.de/idsxces1/DTD/ids.xcesdoc.dtd">
+<idsHeader type="text" pattern="text" status="new" version="1.1" TEIform="teiHeader">
+    <fileDesc>
+     <titleStmt>
+      <textSigle>REI/RBP.00007</textSigle>
+      <t.title assemblage="external">REI/RBP.00007 Richard von Weizsäcker: Ansprache von Bundespräsident Richard von Weizsäcker bei einem Abendessen, gegeben von Königin Beatrix und Prinz Claus im Königlichen Palais Op de Dam, Hrsg: Bundespäsidialamt</t.title>
+     </titleStmt>
+     <publicationStmt>
+      <distributor/>
+      <pubAddress/>
+      <availability region="world">CC-BY-SA</availability>
+      <pubDate/>
+     </publicationStmt>
+     <sourceDesc>
+      <biblStruct>
+       <monogr>
+        <h.title type="main">Ansprache von Bundespräsident Richard von Weizsäcker bei einem Abendessen, gegeben von Königin Beatrix und Prinz Claus im Königlichen Palais Op de Dam</h.title>
+        <h.title type="sub"/>
+        <h.title type="abbr" level="m"/>
+        <h.author>Richard von Weizsäcker</h.author>
+        <editor/>
+        <edition>
+         <further/>
+         <kind>aus: Adrien Barbaresi (2012): German Political Speeches, Corpus and Visualization. 2. Version, ENS Lyon, http://purl.org/corpus/german-speeches</kind>
+         <appearance/>
+        </edition>
+        <imprint>
+         <publisher/>
+         <pubDate type="year">1985</pubDate>
+         <pubDate type="month">05</pubDate>
+         <pubDate type="day">30</pubDate>
+         <pubPlace key="DE">Bonnn</pubPlace>
+        </imprint>
+        <biblScope type="subsume"/>
+        <biblScope type="pp"/>
+        <biblScope type="vol"/>
+        <biblScope type="volume-title"/>
+       </monogr>
+      </biblStruct>
+      <reference type="complete" assemblage="regular">REI/RBP.00007 Richard von Weizsäcker: Ansprache von Bundespräsident Richard von Weizsäcker bei einem Abendessen, gegeben von Königin Beatrix und Prinz Claus im Königlichen Palais Op de Dam, Hrsg: Bundespäsidialamt [Ausführliche Zitierung nicht verfügbar]</reference>
+      <reference type="short" assemblage="regular">REI/RBP.00007 Richard von Weizsäcker: Ansprache von Bundespräsident Richard von Weizsäcker bei einem Abendessen, gegeben von Königin Beatrix und Prinz Claus im Königlichen Palais Op de Dam, Hrsg: Bundespäsidialamt [Kurzzitierung nicht verfügbar]</reference>
+     </sourceDesc>
+    </fileDesc>
+    <encodingDesc>
+     <samplingDecl/>
+     <tagsDecl>
+      <tagUsage gi="ptr" occurs="1"/>
+      <tagUsage gi="p" occurs="2"/>
+      <tagUsage gi="s" occurs="17"/>
+     </tagsDecl>
+    </encodingDesc>
+    <profileDesc>
+     <creation>
+      <creatDate>1985.05.30</creatDate>
+      <creatRef/>
+      <creatRefShort/>
+     </creation>
+     <textClass>
+      <catRef n="0.99" target="topic.politik.ausland" scheme="topic"/>
+     </textClass>
+     <textDesc>
+      <textDomain/>
+     </textDesc>
+    </profileDesc>
+   </idsHeader>
\ No newline at end of file
diff --git a/t/real/corpus/REI/RBP/00007/struct/structure.xml b/t/real/corpus/REI/RBP/00007/struct/structure.xml
new file mode 100644
index 0000000..7071362
--- /dev/null
+++ b/t/real/corpus/REI/RBP/00007/struct/structure.xml
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-model href="span.rng"
+            type="application/xml"
+            schematypens="http://relaxng.org/ns/structure/1.0"?>
+<layer docid="REI_RBP.00007"
+       xmlns="http://ids-mannheim.de/ns/KorAP"
+       version="KorAP-0.4">
+  <spanList>
+    <span id="s0" from="0" to="2664" l="1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">text</f>
+      </fs>
+        </span>
+    <span id="s1" from="0" to="150" l="2">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">front</f>
+      </fs>
+        </span>
+    <span id="s2" from="0" to="150" l="3">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">titlePage</f>
+        <f name="attr">
+          <fs type="attr">
+            <f name="id">rbp.00007-0-titlepage</f>
+          </fs>
+        </f>
+      </fs>
+        </span>
+    <span id="s3" from="0" to="150" l="4">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">docTitle</f>
+      </fs>
+        </span>
+    <span id="s4" from="0" to="150" l="5">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">titlePart</f>
+        <f name="attr">
+          <fs type="attr">
+            <f name="type">unspecified</f>
+          </fs>
+        </f>
+      </fs>
+        </span>
+    <span id="s5" from="150" to="2664" l="2">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">body</f>
+      </fs>
+        </span>
+    <span id="s6" from="150" to="2664" l="3">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">div</f>
+        <f name="attr">
+          <fs type="attr">
+            <f name="n">0</f>
+            <f name="complete">y</f>
+            <f name="type">book</f>
+          </fs>
+        </f>
+      </fs>
+        </span>
+    <span id="s7" from="150" to="150" l="4">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">ptr</f>
+        <f name="attr">
+          <fs type="attr">
+            <f name="type">aligning</f>
+            <f name="targType">head</f>
+            <f name="targOrder">u</f>
+            <f name="target">rbp.00007-0-titlepage</f>
+          </fs>
+        </f>
+      </fs>
+        </span>
+    <span id="s8" from="150" to="1070" l="4">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">p</f>
+      </fs>
+        </span>
+    <span id="s9" from="1070" to="1646" l="4">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">p</f>
+      </fs>
+        </span>
+    <span id="s10" from="1646" to="2664" l="4">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">p</f>
+      </fs>
+        </span>
+    <span id="s11" from="2664" to="2664" l="2">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">back</f>
+      </fs>
+        </span>
+    <span id="s12" from="0" to="353" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s13" from="354" to="592" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s14" from="593" to="654" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s15" from="655" to="856" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s16" from="857" to="923" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s17" from="924" to="1070" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s18" from="1071" to="1262" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s19" from="1263" to="1427" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s20" from="1428" to="1646" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s21" from="1647" to="1825" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s22" from="1826" to="1992" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s23" from="1993" to="2119" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s24" from="2120" to="2200" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s25" from="2201" to="2403" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s26" from="2404" to="2522" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+    <span id="s27" from="2523" to="2664" l="-1">
+      <fs type="struct" xmlns="http://www.tei-c.org/ns/1.0">
+        <f name="name">s</f>
+      </fs>
+        </span>
+  </spanList>
+</layer>
\ No newline at end of file
diff --git a/t/real/corpus/REI/RBP/header.xml b/t/real/corpus/REI/RBP/header.xml
new file mode 100644
index 0000000..6f58701
--- /dev/null
+++ b/t/real/corpus/REI/RBP/header.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-model href="header.rng"
+            type="application/xml"
+            schematypens="http://relaxng.org/ns/structure/1.0"?>
+<!DOCTYPE idsCorpus PUBLIC "-//IDS//DTD IDS-XCES 1.0//EN"
+          "http://corpora.ids-mannheim.de/idsxces1/DTD/ids.xcesdoc.dtd">
+<idsHeader type="document" pattern="text" status="new" version="1.1" TEIform="teiHeader">
+   <fileDesc>
+    <titleStmt>
+     <dokumentSigle>REI/RBP</dokumentSigle>
+     <d.title>Reden deutscher Bundespräsidenten</d.title>
+    </titleStmt>
+    <publicationStmt>
+     <distributor/>
+     <pubAddress/>
+     <availability region="world">CC-BY-SA</availability>
+     <pubDate/>
+    </publicationStmt>
+    <sourceDesc>
+     <biblStruct>
+      <monogr>
+       <h.title type="main"/>
+       <imprint/>
+      </monogr>
+     </biblStruct>
+    </sourceDesc>
+   </fileDesc>
+  </idsHeader>
\ No newline at end of file
diff --git a/t/real/rei.t b/t/real/rei.t
index 6593258..acda3b6 100644
--- a/t/real/rei.t
+++ b/t/real/rei.t
@@ -320,5 +320,75 @@
 is('opennlp/p:NN', $last->[3]);
 is('s:Befreiungsschlag', $last->[4]);
 
+
+# Check with negative level (required for wikidemo conversion)
+$path = catdir(dirname(__FILE__), 'corpus','REI','RBP','00007');
+
+ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
+ok($doc->parse, 'Parse document');
+
+is($doc->text_sigle, 'REI/RBP/00007', 'Correct text sigle');
+is($doc->doc_sigle, 'REI/RBP', 'Correct document sigle');
+is($doc->corpus_sigle, 'REI', 'Correct corpus sigle');
+
+$meta = $doc->meta;
+is($meta->{T_title}, 'Ansprache von Bundespräsident Richard von Weizsäcker bei einem Abendessen, gegeben von Königin Beatrix und Prinz Claus im Königlichen Palais Op de Dam', 'Title');
+ok(!$meta->{T_sub_title}, 'SubTitle');
+is($meta->{T_author}, 'Richard von Weizsäcker', 'Author');
+ok(!$meta->{A_editor}, 'Editor');
+is($meta->{S_pub_place}, 'Bonnn', 'PubPlace'); # sic!
+ok(!$meta->{A_publisher}, 'Publisher');
+
+ok(!$meta->{S_text_type}, 'No Text Type');
+ok(!$meta->{S_text_type_art}, 'No Text Type Art');
+ok(!$meta->{S_text_type_ref}, 'No Text Type Ref');
+ok(!$meta->{S_text_domain}, 'No Text Domain');
+ok(!$meta->{S_text_column}, 'No Text Column');
+
+is($meta->{K_text_class}->[0], 'politik', 'Correct Text Class');
+is($meta->{K_text_class}->[1], 'ausland', 'Correct Text Class');
+ok(!$meta->{K_text_class}->[2], 'Correct Text Class');
+
+is($meta->{D_pub_date}, '19850530', 'Creation date');
+is($meta->{D_creation_date}, '19850530', 'Creation date');
+is($meta->{S_availability}, 'CC-BY-SA', 'License');
+ok(!$meta->{A_pages}, 'Pages');
+
+ok(!$meta->{A_file_edition_statement}, 'File Statement');
+ok(!$meta->{A_bibl_edition_statement}, 'Bibl Statement');
+
+# Get tokenization
+$tokens = KorAP::XML::Tokenizer->new(
+  path => $doc->path,
+  doc => $doc,
+  foundry => $token_base_foundry,
+  layer => 'tokens',
+  name => 'tokens'
+);
+
+ok($tokens, 'Token Object is fine');
+ok($tokens->parse, 'Token parsing is fine');
+ok(!$tokens->error);
+
+$tokens->add('DeReKo', 'Structure', 'base-sentences-paragraphs-pagebreaks');
+ok(!$tokens->error);
+
+$output = decode_json( $tokens->to_json );
+
+is(substr($output->{data}->{text}, 0, 100), 'Ansprache von Bundespräsident Richard von Weizsäcker bei einem Abendessen, gegeben von Königin Beatr', 'Primary Data');
+
+is($output->{data}->{foundries}, 'dereko dereko/structure dereko/structure/base-sentences-paragraphs-pagebreaks', 'Foundries');
+is($output->{data}->{layerInfos}, 'dereko/s=spans', 'layerInfos');
+
+my $stream = $output->{data}->{stream};
+
+is($stream->[0]->[0], '-:base/paragraphs$<i>3');
+is($stream->[0]->[1], '-:base/sentences$<i>16');
+is($stream->[0]->[2], '-:tokens$<i>418');
+is($stream->[0]->[7], '<>:base/s:s$<b>64<i>0<i>353<i>53<b>2');
+is($stream->[0]->[8], '<>:base/s:t$<b>64<i>0<i>2664<i>418<b>0');
+
+is(index(join('',@{$stream->[0]}), '<>:dereko/s:s$'), -1);
+
 done_testing;
 __END__