far from perfect, but the road is straight now; adding the structure.xml doc, a bit schizophrenic in the indexing
Change-Id: I6d1cf3e309cc647f942e4bb598ee690a9a1bc871
diff --git a/nkjp2korap.xsl b/nkjp2korap.xsl
index 126752d..729d916 100644
--- a/nkjp2korap.xsl
+++ b/nkjp2korap.xsl
@@ -69,7 +69,7 @@
<xsl:mode name="header-text" on-no-match="text-only-copy"/>
<xsl:mode use-accumulators="#all"/>
- <xsl:accumulator name="elem-offset-seq" as="map(xs:string, item())+" initial-value="(map{})">
+ <xsl:accumulator name="elem-offset-seq" as="map(xs:string, item()+)+" initial-value="(map{})">
<xsl:accumulator-rule match="tei:w[parent::tei:seg[count(@nkjp:rejected) eq 0]]" phase="end">
<xsl:variable name="previous_index" as="xs:integer">
<xsl:choose>
@@ -77,20 +77,29 @@
<xsl:sequence select="0"/>
</xsl:when>
<xsl:otherwise>
- <xsl:sequence select="map:get(head(reverse($value)),'end')"/>
+ <xsl:variable name="grab_the_tip" as="map(*)" select="head(reverse($value))"/>
+ <xsl:sequence select="map:get($grab_the_tip,map:keys($grab_the_tip)[1])[2]"/>
+ <xsl:message select="'previous element:' || map:keys($grab_the_tip)[1]"></xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
+ <xsl:variable name="our_base" as="xs:integer" select="$previous_index + xs:integer(f:is_preceded_by_ws(parent::tei:seg))"/>
-<!--<xsl:message select="'previous_index:' || $previous_index"></xsl:message>-->
+ <xsl:message select="'previous_index:' || $previous_index || 'our_base: ' || $our_base"/>
<xsl:sequence select="
$value,
map {
- 'id': string(parent::tei:seg/@xml:id),
- 'start': $previous_index + xs:integer(f:is_preceded_by_ws(parent::tei:seg)),
- 'end': string-length()
+ string(parent::tei:seg/@xml:id): ($our_base,$our_base + string-length() - 1)
}"/>
+
+<!-- <xsl:sequence select="
+ $value,
+ map {
+ 'id': string(parent::tei:seg/@xml:id),
+ 'start': $previous_index + xs:integer(f:is_preceded_by_ws(parent::tei:seg)), messed up
+ 'end': string-length()
+ }"/>-->
</xsl:accumulator-rule>
</xsl:accumulator>
@@ -428,15 +437,10 @@
<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="offsets" as="map(xs:string, xs:integer+)" tunnel="yes"/>
+ <!--<xsl:param name="offsets" as="map(xs:string, xs:integer+)" tunnel="yes"/>-->
- <xsl:variable name="offsets" as="map(xs:string, xs:integer+)">
- <xsl:map>
- <xsl:for-each select="tail(fn:accumulator-after('elem-offset-seq'))">
- <xsl:map-entry key="map:get(., 'id')" select="map:get(., 'start'), map:get(., 'end')"/>
- </xsl:for-each>
- </xsl:map>
- </xsl:variable>
+ <xsl:variable name="offsets" as="map(xs:string, xs:integer+)"
+ select="map:merge(tail(fn:accumulator-after('elem-offset-seq')))"/>
<!-- <xsl:message select="'size of offsets in tei:* ' || map:size($offsets)"/>-->
@@ -511,7 +515,7 @@
<xsl:attribute name="id" select="'s' || $my_index"/>
<xsl:attribute name="from" select="$start"/>
<xsl:attribute name="to" select="$end"/>
- <xsl:attribute name="accumulator" select="string-join(map:get($offsets,string(@xml:id)))"/>
+ <xsl:attribute name="accumulator" select="string-join(map:get($offsets,string(@xml:id)),',')"/> <!--test-->
<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 -->
@@ -519,6 +523,12 @@
<xsl:attribute name="name" select="'name'"/>
<xsl:value-of select="local-name()"/>
</xsl:element>
+ <xsl:if test="local-name() eq 'seg'"> <!--test-->
+ <xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
+ <xsl:attribute name="name" select="'orth'"/>
+ <xsl:value-of select="fn:normalize-space(.)"/>
+ </xsl:element>
+ </xsl:if>
<xsl:if test="count(@*)">
<xsl:element name="f" namespace="http://www.tei-c.org/ns/1.0">
<xsl:attribute name="name" select="'attr'"/>