fix structure.xml, create morpho.xml

Change-Id: Idd0c44671b6a975626b0a9d40a1999a02e7a1148
diff --git a/nkjp2korap.xsl b/nkjp2korap.xsl
index 46b4bb6..ff1ee50 100644
--- a/nkjp2korap.xsl
+++ b/nkjp2korap.xsl
@@ -101,6 +101,8 @@
 
     <xsl:call-template name="create_morpho">
       <xsl:with-param name="text.xml" select="$text.xml" as="document-node()"/>
+      <xsl:with-param name="ann_segmentation.xml" select="$ann_segmentation.xml"
+        as="document-node()"/>
       <xsl:with-param name="ann_morphosyntax.xml" select="$ann_morphosyntax.xml"
         as="document-node()"/>
       <xsl:with-param name="target" select="$targetTextDir || 'nkjp/morpho.xml'" as="xs:string"/>
@@ -167,7 +169,7 @@
     <xsl:param name="index" as="xs:integer" required="no" select="1"/>
     <!-- I have made a major mess here, but it works... it's so spread out 
       because I wanted to make sure to be able to look up the individual 
-      constituent values, should anything go wrong   -->
+      constituent values, should anything go wrong; optimization will come when it's worked against a larger dataset   -->
     <xsl:variable name="my_name" select="local-name()" as="xs:string"/>
     <xsl:variable name="preceding" select="preceding-sibling::*[local-name(.) eq $my_name]"/>
     <xsl:variable name="preceding-count" select="count($preceding)"/>
@@ -221,14 +223,17 @@
     </xsl:variable>
     <xsl:variable name="end" as="xs:integer" select="f:calc_content_length(.)">
     </xsl:variable>
+    
     <xsl:element name="span" namespace="{$KorAP_namespace}">
       <xsl:attribute name="id" select="'s' || $my_index"/>
       <xsl:attribute name="from" select="$start"/>
       <xsl:attribute name="to" select="$end"/>
       <xsl:attribute name="l" select="f:compute_nesting(.)"/>
       <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
+        <xsl:attribute name="type" select="'struct'"></xsl:attribute>  <!-- STRUCT vs. LEX -->
         <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
-          <xsl:attribute name="name" select="local-name()"/>
+          <xsl:attribute name="name" select="'name'"/>
+          <xsl:value-of select="local-name()"/>
         </xsl:element>
         <xsl:if test="count(@*)">
           <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
@@ -257,17 +262,183 @@
 
   <xsl:template name="create_morpho">
     <xsl:param name="text.xml" as="document-node()"/>
+    <xsl:param name="ann_segmentation.xml" as="document-node()"/>
     <xsl:param name="ann_morphosyntax.xml" as="document-node()"/>
     <xsl:param name="target" as="xs:string"/>
 
     <xsl:result-document encoding="UTF-8" method="xml" indent="yes"
       xpath-default-namespace="http://ids-mannheim.de/ns/KorAP" href="{$target}">
       <xsl:processing-instruction name="xml-model">href=&quot;span.rng&quot; type=&quot;application/xml&quot; schematypens=&quot;http://relaxng.org/ns/structure/1.0&quot;</xsl:processing-instruction>
-
+      <xsl:element name="layer" namespace="{$KorAP_namespace}">
+        <xsl:attribute name="docid" select="$compoundID"/>
+        <xsl:attribute name="version" select="$KorAP-XML_version"/>
+        
+        <xsl:element name="spanList" namespace="{$KorAP_namespace}">
+          <xsl:apply-templates select="$ann_segmentation.xml//tei:text" mode="morpho">
+            <xsl:with-param name="ann_morphosyntax.xml" select="$ann_morphosyntax.xml" as="document-node()"/>
+          </xsl:apply-templates>          
+        </xsl:element>
+      </xsl:element>
     </xsl:result-document>
   </xsl:template>
 
+  <xsl:template match="tei:*" mode="morpho">
+    <xsl:param name="ini" as="xs:integer" required="no" select="0"/>
+    <xsl:param name="fin" as="xs:integer" required="no" select="999999999"/>
+    <xsl:param name="index" as="xs:integer" required="no" select="1"/>
+    <xsl:param name="ann_morphosyntax.xml" as="document-node()"/>
+    <xsl:variable name="my_name" select="local-name()" as="xs:string"/>
+    <xsl:variable name="preceding" select="preceding-sibling::*[local-name(.) eq $my_name]"/>
+    <xsl:variable name="preceding-count" select="count($preceding)"/>
+    <xsl:variable name="outside-preceding-count" as="xs:integer">
+      <xsl:choose>
+        <xsl:when test="self::tei:s or self::tei:p">
+          <xsl:choose>
+            <xsl:when test="$preceding-count">
+              <xsl:sequence select="
+                sum(for $p in $preceding
+                return
+                count($p/descendant::*))"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:sequence select="0"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:sequence select="0"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="my_index" select="$index + 1 + $preceding-count + $outside-preceding-count"
+      as="xs:integer"/>
+    
+    <xsl:variable name="start" as="xs:integer">
+      <xsl:choose>
+        <xsl:when test="self::tei:text or self::tei:body">
+          <xsl:sequence select="0"/>
+        </xsl:when>
+        <xsl:when test="self::tei:p">
+          <xsl:variable name="first_corresp"
+            select="descendant::tei:s[1]/descendant::tei:seg[1]/attribute::corresp"
+            as="attribute(corresp)"/>
+          <xsl:variable name="numbers" select="substring-after(substring-before($first_corresp,')'),',')"/>
+          <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
+        </xsl:when>
+        <xsl:when test="self::tei:s">
+          <xsl:variable name="first_corresp"
+            select="descendant::tei:seg[1]/attribute::corresp"
+            as="attribute(corresp)"/>
+          <xsl:variable name="numbers" select="substring-after(substring-before($first_corresp,')'),',')"/>
+          <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
+        </xsl:when>
+        <!--<xsl:when test="self::tei:seg">
+          <xsl:variable name="numbers" select="substring-after(substring-before(@corresp,')'),',')"/>
+          <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
+        </xsl:when>-->
+      </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="end" as="xs:integer" select="f:calc_content_length(.)">
+    </xsl:variable>
+    
+    <xsl:apply-templates mode="morpho">
+      <xsl:with-param name="ini" select="$start" as="xs:integer"/>
+      <xsl:with-param name="fin" select="$end" as="xs:integer"/>
+      <xsl:with-param name="index" select="$my_index"/>
+      <xsl:with-param name="ann_morphosyntax.xml" select="$ann_morphosyntax.xml" as="document-node()"/>
+    </xsl:apply-templates>
+  </xsl:template>
 
+  <xsl:template match="tei:seg" mode="morpho">
+    <xsl:param name="ini" as="xs:integer" required="no" select="0"/>
+    <xsl:param name="fin" as="xs:integer" required="no" select="999999999"/>
+    <xsl:param name="index" as="xs:integer" required="no" select="1"/>
+    <xsl:param name="ann_morphosyntax.xml" as="document-node()"/>
+    <!-- I have made a major mess here, but it works... it's so spread out 
+      because I wanted to make sure to be able to look up the individual 
+      constituent values, should anything go wrong   -->
+    <xsl:variable name="my_name" select="local-name()" as="xs:string"/>
+    <xsl:variable name="my_id" select="@xml:id" as="xs:string"/>
+    <xsl:variable name="my_morph-seg" as="node()" select="$ann_morphosyntax.xml//tei:seg[substring-after(@corresp,'#') eq $my_id]"/>
+    <xsl:variable name="my_disamb" select="$my_morph-seg//tei:fs/tei:f[@name eq 'disamb']" as="node()"/>
+    <xsl:variable name="my_choice-id" select="substring-after($my_disamb//tei:f[@name eq 'choice']/@fVal,'#')" as="xs:string"/>
+    <xsl:variable name="my_choice-lex" select="$my_morph-seg//tei:f[@name eq 'interps']/tei:fs[@type eq 'lex'][descendant::tei:symbol[@xml:id eq $my_choice-id]]" as="node()"/>
+    <xsl:variable name="chosen-msd" as="xs:string" select="$my_choice-lex/descendant::tei:symbol[@xml:id eq $my_choice-id]/@value"/>
+    <xsl:variable name="preceding" select="preceding-sibling::*[local-name(.) eq $my_name]"/>
+    <xsl:variable name="preceding-count" select="count($preceding)"/>
+    <xsl:variable name="outside-preceding-count" as="xs:integer">
+      <xsl:choose>
+        <xsl:when test="self::tei:s or self::tei:p">
+          <xsl:choose>
+            <xsl:when test="$preceding-count">
+              <xsl:sequence select="
+                sum(for $p in $preceding
+                return
+                count($p/descendant::*))"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:sequence select="0"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:sequence select="0"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="my_index" select="$index + 1 + $preceding-count + $outside-preceding-count"
+      as="xs:integer"/>
+    
+    <xsl:variable name="start" as="xs:integer">
+      <xsl:variable name="numbers" select="substring-after(substring-before(@corresp,')'),',')"/>
+      <xsl:sequence select="xs:integer(substring-before($numbers,','))"/>
+    </xsl:variable>
+    <xsl:variable name="end" as="xs:integer" select="f:calc_content_length(.)">
+    </xsl:variable>
+    <xsl:element name="span" namespace="{$KorAP_namespace}">
+      <xsl:attribute name="id" select="'s' || $my_index"/>
+      <xsl:attribute name="from" select="$start"/>
+      <xsl:attribute name="to" select="$end"/>
+      <xsl:attribute name="l" select="f:compute_nesting(.)"/>
+      <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
+        <xsl:attribute name="type" select="'lex'"/>
+        <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
+          <xsl:attribute name="name" select="'lex'"/>
+          <xsl:element name="fs" namespace="http://www.tei-c.org/ns/1.0">
+            <xsl:comment select="$my_morph-seg//tei:fs/tei:f[@name eq 'orth']/tei:string"/>
+            
+            
+            <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
+              <xsl:attribute name="name" select="'lemma'"/>
+              <xsl:value-of select="$my_choice-lex/tei:f[@name eq 'base']/tei:string"/>
+            </xsl:element>
+            <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
+              <xsl:attribute name="name" select="'pos'"/>
+              <xsl:value-of select="$my_choice-lex/tei:f[@name eq 'ctag']/tei:symbol/@value"/>
+            </xsl:element>
+            <xsl:if test="string-length($chosen-msd)">
+              <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
+                <xsl:attribute name="name" select="'msd'"/>
+                <xsl:value-of select="$chosen-msd"/>
+              </xsl:element>
+            </xsl:if>
+            <xsl:if test="$my_morph-seg//tei:fs/tei:f[@name eq 'nps']">
+              <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
+                <xsl:attribute name="name" select="'join'"/>
+                <xsl:value-of select="'left'"/>
+              </xsl:element>
+            </xsl:if>
+          </xsl:element>
+        </xsl:element>
+      </xsl:element>
+    </xsl:element>
+    <xsl:apply-templates mode="morpho">
+      <xsl:with-param name="ini" select="$start" as="xs:integer"/>
+      <xsl:with-param name="fin" select="$end" as="xs:integer"/>
+      <xsl:with-param name="index" select="$my_index"/>
+      <xsl:with-param name="ann_morphosyntax.xml" select="$ann_morphosyntax.xml" as="document-node()"/>
+    </xsl:apply-templates>
+  </xsl:template>
   <!--   **************************        TEXT header      *******************                -->
 
   <xsl:template name="create_text_header">
diff --git a/test/output/NKJP/NKJP/KOT/nkjp/morpho.xml b/test/output/NKJP/NKJP/KOT/nkjp/morpho.xml
index e69de29..5bcbb7c 100644
--- a/test/output/NKJP/NKJP/KOT/nkjp/morpho.xml
+++ b/test/output/NKJP/NKJP/KOT/nkjp/morpho.xml
@@ -0,0 +1,532 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-model href="span.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
+<layer xmlns="http://ids-mannheim.de/ns/KorAP"
+       docid="NKJP_NKJP.KOT"
+       version="KorAP-0.4">
+   <spanList>
+      <span id="s6" from="0" to="3" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--Nie-->
+                  <f name="lemma">nie</f>
+                  <f name="pos">qub</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s7" from="4" to="11" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--zdążyła-->
+                  <f name="lemma">zdążyć</f>
+                  <f name="pos">praet</f>
+                  <f name="msd">sg:f:perf</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s8" from="11" to="12" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--m-->
+                  <f name="lemma">być</f>
+                  <f name="pos">aglt</f>
+                  <f name="msd">sg:pri:imperf:nwok</f>
+                  <f name="join">left</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s9" from="13" to="20" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--jeszcze-->
+                  <f name="lemma">jeszcze</f>
+                  <f name="pos">qub</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s10" from="21" to="32" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--doprowadzić-->
+                  <f name="lemma">doprowadzić</f>
+                  <f name="pos">inf</f>
+                  <f name="msd">perf</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s11" from="33" to="43" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--mieszkania-->
+                  <f name="lemma">mieszkanie</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:gen:n</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s12" from="44" to="46" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--do-->
+                  <f name="lemma">do</f>
+                  <f name="pos">prep</f>
+                  <f name="msd">gen</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s13" from="47" to="51" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--ładu-->
+                  <f name="lemma">ład</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:gen:m3</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s14" from="52" to="54" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--po-->
+                  <f name="lemma">po</f>
+                  <f name="pos">prep</f>
+                  <f name="msd">loc</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s15" from="55" to="62" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--rządach-->
+                  <f name="lemma">rząd</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">pl:loc:m3</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s16" from="63" to="67" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--Mini-->
+                  <f name="lemma">Minia</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:gen:f</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s17" from="67" to="68" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--,-->
+                  <f name="lemma">,</f>
+                  <f name="pos">interp</f>
+                  <f name="join">left</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s18" from="69" to="74" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--która-->
+                  <f name="lemma">który</f>
+                  <f name="pos">adj</f>
+                  <f name="msd">sg:nom:f:pos</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s19" from="75" to="82" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--zrobiła-->
+                  <f name="lemma">zrobić</f>
+                  <f name="pos">praet</f>
+                  <f name="msd">sg:f:perf</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s20" from="83" to="84" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--w-->
+                  <f name="lemma">w</f>
+                  <f name="pos">prep</f>
+                  <f name="msd">loc:nwok</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s21" from="85" to="88" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--nim-->
+                  <f name="lemma">on</f>
+                  <f name="pos">ppron3</f>
+                  <f name="msd">sg:loc:n:ter:akc:praep</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s22" from="89" to="94" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--maksi-->
+                  <f name="lemma">maksi</f>
+                  <f name="pos">adj</f>
+                  <f name="msd">sg:acc:m3:pos</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s23" from="95" to="102" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--bałagan-->
+                  <f name="lemma">bałagan</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:acc:m3</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s24" from="102" to="103" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--,-->
+                  <f name="lemma">,</f>
+                  <f name="pos">interp</f>
+                  <f name="join">left</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s25" from="104" to="109" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--kiedy-->
+                  <f name="lemma">kiedy</f>
+                  <f name="pos">adv</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s26" from="110" to="112" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--na-->
+                  <f name="lemma">na</f>
+                  <f name="pos">prep</f>
+                  <f name="msd">loc</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s27" from="113" to="123" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--horyzoncie-->
+                  <f name="lemma">horyzont</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:loc:m3</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s28" from="124" to="126" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--za-->
+                  <f name="lemma">za</f>
+                  <f name="pos">prep</f>
+                  <f name="msd">inst</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s29" from="127" to="133" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--sprawą-->
+                  <f name="lemma">sprawa</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:inst:f</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s30" from="134" to="138" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--pani-->
+                  <f name="lemma">pani</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:gen:f</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s31" from="139" to="144" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--Joasi-->
+                  <f name="lemma">Joasia</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:gen:f</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s32" from="145" to="152" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--pojawił-->
+                  <f name="lemma">pojawić</f>
+                  <f name="pos">praet</f>
+                  <f name="msd">sg:m2:perf</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s33" from="153" to="156" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--się-->
+                  <f name="lemma">się</f>
+                  <f name="pos">qub</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s34" from="157" to="163" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--czarny-->
+                  <f name="lemma">czarny</f>
+                  <f name="pos">adj</f>
+                  <f name="msd">sg:nom:m2:pos</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s35" from="164" to="167" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--jak-->
+                  <f name="lemma">jak</f>
+                  <f name="pos">prep</f>
+                  <f name="msd">nom</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s36" from="168" to="173" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--smoła-->
+                  <f name="lemma">smoła</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:nom:f</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s37" from="174" to="182" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--Dratewka-->
+                  <f name="lemma">Dratewka</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:nom:m2</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s38" from="182" to="183" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--.-->
+                  <f name="lemma">.</f>
+                  <f name="pos">interp</f>
+                  <f name="join">left</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s40" from="184" to="192" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--Dratewkę-->
+                  <f name="lemma">Dratewka</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:acc:m2</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s41" from="193" to="197" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--pani-->
+                  <f name="lemma">pani</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:nom:f</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s42" from="198" to="204" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--Joasia-->
+                  <f name="lemma">Joasia</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:nom:f</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s43" from="205" to="212" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--wyrwała-->
+                  <f name="lemma">wyrwać</f>
+                  <f name="pos">praet</f>
+                  <f name="msd">sg:f:perf</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s44" from="213" to="214" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--z-->
+                  <f name="lemma">z</f>
+                  <f name="pos">prep</f>
+                  <f name="msd">gen:nwok</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s45" from="215" to="227" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--bestialskich-->
+                  <f name="lemma">bestialski</f>
+                  <f name="pos">adj</f>
+                  <f name="msd">pl:gen:f:pos</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s46" from="228" to="231" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--łap-->
+                  <f name="lemma">łapa</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">pl:gen:f</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s47" from="232" to="239" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--pewnego-->
+                  <f name="lemma">pewien</f>
+                  <f name="pos">adj</f>
+                  <f name="msd">sg:gen:m1:pos</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s48" from="240" to="246" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--szewca-->
+                  <f name="lemma">szewc</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:gen:m1</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s49" from="246" to="247" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--,-->
+                  <f name="lemma">,</f>
+                  <f name="pos">interp</f>
+                  <f name="join">left</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s50" from="248" to="255" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--którego-->
+                  <f name="lemma">który</f>
+                  <f name="pos">adj</f>
+                  <f name="msd">sg:acc:m1:pos</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s51" from="256" to="261" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--niech-->
+                  <f name="lemma">niech</f>
+                  <f name="pos">qub</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s52" from="262" to="268" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--piekło-->
+                  <f name="lemma">piekło</f>
+                  <f name="pos">subst</f>
+                  <f name="msd">sg:nom:n</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s53" from="269" to="278" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--pochłonie-->
+                  <f name="lemma">pochłonąć</f>
+                  <f name="pos">fin</f>
+                  <f name="msd">sg:ter:perf</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+      <span id="s54" from="278" to="279" l="5">
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="lex">
+            <f name="lex">
+               <fs><!--.-->
+                  <f name="lemma">.</f>
+                  <f name="pos">interp</f>
+                  <f name="join">left</f>
+               </fs>
+            </f>
+         </fs>
+      </span>
+   </spanList>
+</layer>
diff --git a/test/output/NKJP/NKJP/KOT/struct/structure.xml b/test/output/NKJP/NKJP/KOT/struct/structure.xml
index 642a74b..0d711ea 100644
--- a/test/output/NKJP/NKJP/KOT/struct/structure.xml
+++ b/test/output/NKJP/NKJP/KOT/struct/structure.xml
@@ -5,8 +5,8 @@
        version="KorAP-0.4">
    <spanList>
       <span id="s2" from="0" to="279" l="1">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="text"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">text</f>
             <f name="attr">
                <fs type="attr">
                   <f name="id">segm_text</f>
@@ -16,8 +16,8 @@
          </fs>
       </span>
       <span id="s3" from="0" to="279" l="2">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="body"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">body</f>
             <f name="attr">
                <fs type="attr">
                   <f name="id">segm_body</f>
@@ -26,8 +26,8 @@
          </fs>
       </span>
       <span id="s4" from="0" to="279" l="3">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="p"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">p</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#txt_76-div</f>
@@ -37,8 +37,8 @@
          </fs>
       </span>
       <span id="s5" from="0" to="183" l="4">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="s"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">s</f>
             <f name="attr">
                <fs type="attr">
                   <f name="id">segm_76.33-s</f>
@@ -50,8 +50,8 @@
          </fs>
       </span>
       <span id="s6" from="0" to="3" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,0,3)</f>
@@ -65,8 +65,8 @@
          </fs>
       </span>
       <span id="s7" from="4" to="11" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,4,7)</f>
@@ -80,8 +80,8 @@
          </fs>
       </span>
       <span id="s8" from="11" to="12" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,11,1)</f>
@@ -95,8 +95,8 @@
          </fs>
       </span>
       <span id="s9" from="13" to="20" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,13,7)</f>
@@ -110,8 +110,8 @@
          </fs>
       </span>
       <span id="s10" from="21" to="32" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,21,11)</f>
@@ -125,8 +125,8 @@
          </fs>
       </span>
       <span id="s11" from="33" to="43" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,33,10)</f>
@@ -140,8 +140,8 @@
          </fs>
       </span>
       <span id="s12" from="44" to="46" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,44,2)</f>
@@ -155,8 +155,8 @@
          </fs>
       </span>
       <span id="s13" from="47" to="51" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,47,4)</f>
@@ -170,8 +170,8 @@
          </fs>
       </span>
       <span id="s14" from="52" to="54" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,52,2)</f>
@@ -185,8 +185,8 @@
          </fs>
       </span>
       <span id="s15" from="55" to="62" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,55,7)</f>
@@ -200,8 +200,8 @@
          </fs>
       </span>
       <span id="s16" from="63" to="67" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,63,4)</f>
@@ -215,8 +215,8 @@
          </fs>
       </span>
       <span id="s17" from="67" to="68" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,67,1)</f>
@@ -230,8 +230,8 @@
          </fs>
       </span>
       <span id="s18" from="69" to="74" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,69,5)</f>
@@ -245,8 +245,8 @@
          </fs>
       </span>
       <span id="s19" from="75" to="82" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,75,7)</f>
@@ -260,8 +260,8 @@
          </fs>
       </span>
       <span id="s20" from="83" to="84" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,83,1)</f>
@@ -275,8 +275,8 @@
          </fs>
       </span>
       <span id="s21" from="85" to="88" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,85,3)</f>
@@ -290,8 +290,8 @@
          </fs>
       </span>
       <span id="s22" from="89" to="94" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,89,5)</f>
@@ -305,8 +305,8 @@
          </fs>
       </span>
       <span id="s23" from="95" to="102" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,95,7)</f>
@@ -320,8 +320,8 @@
          </fs>
       </span>
       <span id="s24" from="102" to="103" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,102,1)</f>
@@ -335,8 +335,8 @@
          </fs>
       </span>
       <span id="s25" from="104" to="109" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,104,5)</f>
@@ -350,8 +350,8 @@
          </fs>
       </span>
       <span id="s26" from="110" to="112" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,110,2)</f>
@@ -365,8 +365,8 @@
          </fs>
       </span>
       <span id="s27" from="113" to="123" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,113,10)</f>
@@ -380,8 +380,8 @@
          </fs>
       </span>
       <span id="s28" from="124" to="126" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,124,2)</f>
@@ -395,8 +395,8 @@
          </fs>
       </span>
       <span id="s29" from="127" to="133" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,127,6)</f>
@@ -410,8 +410,8 @@
          </fs>
       </span>
       <span id="s30" from="134" to="138" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,134,4)</f>
@@ -425,8 +425,8 @@
          </fs>
       </span>
       <span id="s31" from="139" to="144" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,139,5)</f>
@@ -440,8 +440,8 @@
          </fs>
       </span>
       <span id="s32" from="145" to="152" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,145,7)</f>
@@ -455,8 +455,8 @@
          </fs>
       </span>
       <span id="s33" from="153" to="156" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,153,3)</f>
@@ -470,8 +470,8 @@
          </fs>
       </span>
       <span id="s34" from="157" to="163" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,157,6)</f>
@@ -485,8 +485,8 @@
          </fs>
       </span>
       <span id="s35" from="164" to="167" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,164,3)</f>
@@ -500,8 +500,8 @@
          </fs>
       </span>
       <span id="s36" from="168" to="173" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,168,5)</f>
@@ -515,8 +515,8 @@
          </fs>
       </span>
       <span id="s37" from="174" to="182" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,174,8)</f>
@@ -530,8 +530,8 @@
          </fs>
       </span>
       <span id="s38" from="182" to="183" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,182,1)</f>
@@ -545,8 +545,8 @@
          </fs>
       </span>
       <span id="s39" from="184" to="279" l="4">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="s"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">s</f>
             <f name="attr">
                <fs type="attr">
                   <f name="id">segm_76.48-s</f>
@@ -558,8 +558,8 @@
          </fs>
       </span>
       <span id="s40" from="184" to="192" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,184,8)</f>
@@ -573,8 +573,8 @@
          </fs>
       </span>
       <span id="s41" from="193" to="197" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,193,4)</f>
@@ -588,8 +588,8 @@
          </fs>
       </span>
       <span id="s42" from="198" to="204" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,198,6)</f>
@@ -603,8 +603,8 @@
          </fs>
       </span>
       <span id="s43" from="205" to="212" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,205,7)</f>
@@ -618,8 +618,8 @@
          </fs>
       </span>
       <span id="s44" from="213" to="214" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,213,1)</f>
@@ -633,8 +633,8 @@
          </fs>
       </span>
       <span id="s45" from="215" to="227" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,215,12)</f>
@@ -648,8 +648,8 @@
          </fs>
       </span>
       <span id="s46" from="228" to="231" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,228,3)</f>
@@ -663,8 +663,8 @@
          </fs>
       </span>
       <span id="s47" from="232" to="239" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,232,7)</f>
@@ -678,8 +678,8 @@
          </fs>
       </span>
       <span id="s48" from="240" to="246" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,240,6)</f>
@@ -693,8 +693,8 @@
          </fs>
       </span>
       <span id="s49" from="246" to="247" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,246,1)</f>
@@ -708,8 +708,8 @@
          </fs>
       </span>
       <span id="s50" from="248" to="255" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,248,7)</f>
@@ -723,8 +723,8 @@
          </fs>
       </span>
       <span id="s51" from="256" to="261" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,256,5)</f>
@@ -738,8 +738,8 @@
          </fs>
       </span>
       <span id="s52" from="262" to="268" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,262,6)</f>
@@ -753,8 +753,8 @@
          </fs>
       </span>
       <span id="s53" from="269" to="278" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,269,9)</f>
@@ -768,8 +768,8 @@
          </fs>
       </span>
       <span id="s54" from="278" to="279" l="5">
-         <fs xmlns="http://www.tei-c.org/ns/1.0">
-            <f name="seg"/>
+         <fs xmlns="http://www.tei-c.org/ns/1.0" type="struct">
+            <f name="name">seg</f>
             <f name="attr">
                <fs type="attr">
                   <f name="corresp">text.xml#string-range(txt_76.1-ab,278,1)</f>