From 9df8f842737d2bed81bb6023955a06392a605804 Mon Sep 17 00:00:00 2001
From: Uwe Sikora <sikora@sub.uni-goettingen.de>
Date: Mon, 26 Mar 2018 16:40:40 +0200
Subject: [PATCH] added tei:rdg[@type=pp|pt] to left-branch-axis

---
 data/samples/Unbenannt1.xml                   | 107 +++++++++++++++++-
 data/samples/rdg_om.xml                       |  49 ++++++++
 .../intermediate_format/identification.xqm    |   9 +-
 oxygen/intermediate_format.oxygen.devel.xqm   |  62 +++++-----
 repo.xml                                      |   1 +
 rest/test/interform.test.xql                  |   7 +-
 6 files changed, 199 insertions(+), 36 deletions(-)
 create mode 100644 data/samples/rdg_om.xml

diff --git a/data/samples/Unbenannt1.xml b/data/samples/Unbenannt1.xml
index 462e616..0cd10af 100644
--- a/data/samples/Unbenannt1.xml
+++ b/data/samples/Unbenannt1.xml
@@ -8,10 +8,41 @@
             <title>Title</title>
          </titleStmt>
          <publicationStmt>
-            <p>Publication Information</p>
+            <p>
+                    <publisher>Publication</publisher> Information</p>
          </publicationStmt>
          <sourceDesc>
-            <p>Information about the source</p>
+            <listWit>
+               <witness xml:id="a">
+                  <desc>1. Aufl. 1779</desc>
+                  <bibl>D. Johann Jakob Griesbach's Anleitung zur gelehrten Kenntnis der populären
+                     Dogmatik. Jena, mit Hellers Schriften, 1779</bibl>
+               </witness>
+               <witness xml:id="b">
+                  <desc>2. Aufl. 1786</desc>
+                  <bibl>D. Johann Jakob Griesbach's, Sachsen Weimar- und Eisenachischen Geheimen
+                     Kirchenraths und ersten Lehrers der Theologie zu Jena, Anleitung zum Studium der
+                     populären Dogmatik, besonders für künftige Religionslehrer. Zweite stark vermehrte
+                     Ausgabe. Mit Churfürstl. Sächßis. gnädigsten Privilegien. Jena, im Verlag der
+                     Cunoischen Erben. 1786</bibl>
+               </witness>
+               <witness xml:id="c">
+                  <desc type="base-text">3. Aufl. 1787</desc>
+                  <bibl>D. Johann Jakob Griesbach's, Sachsen Weimar- und Eisenachischen Geheimen
+                     Kirchenraths und ersten Lehrers der Theologie zu Jena, Anleitung zum Studium der
+                     populären Dogmatik, besonders für künftige Religionslehrer. Dritte verbesserte
+                     Ausgabe. Mit Churfürstl. Sächßis. gnädigsten Privilegien. Jena, im Verlag der
+                     Cunoischen Erben. 1787</bibl>
+               </witness>
+               <witness xml:id="d">
+                  <desc>4. Aufl. 1789</desc>
+                  <bibl>D. Johann Jakob Griesbach's, Sachsen Weimar- und Eisenachischen Geheimen
+                     Kirchenraths und ersten Lehrers der Theologie zu Jena, Anleitung zum Studium der
+                     populären Dogmatik, besonders für künftige Religionslehrer. Vierte neu
+                     durchgesehene Ausgabe. Mit Churfürstl. Sächßis. gnädigsten Privilegien. Jena, bei
+                     Christ. Heinr. Cuno's Erben. 1789.</bibl>
+               </witness>
+            </listWit>
          </sourceDesc>
       </fileDesc>
    </teiHeader>
@@ -177,23 +208,89 @@
                      <lem>trtrlem</lem>
                   <rdg wit="#f" type="om"/>   
                      <rdg wit="#a" type="ptl">tata</rdg>
-                     <rdg wit="#b" type="ptl">tbtb</rdg>
+                     <rdg wit="#b" type="ptl">tb<ptr target="#blabla"/>tb</rdg>
                      <rdg wit="#c" type="om"/>
                      <rdg wit="#d" type="om"/> 
                   <rdg wit="#e" type="om"/>   
                      <rdg wit="#z" type="ppl">zzzz</rdg>
                   </app>
-                    </rdg>
+               </rdg>
+                    <ptr target="#uwes"/>
                <rdg type="ppl" wit="#b">
-                        <note>
+                        <note type="authorial" xml:id="blabla" place="end">
                             <p>
                                 <name>name <p>zweites p</p>
                                 </name>
                             </p>
                         </note>
+                  <note type="editorial" xml:id="uwes" place="end">
+                     <p>
+                        <name>name <p>zweites p</p>
+                        </name>
+                     </p>
+                  </note>
+                  <note type="authorial" place="end">
+                     <seg>label</seg>
+                     <seg>kein label <ptr target="#uwes"/>
+                            </seg>
+                     <p>
+                        <name>name <p>zweites p</p>
+                        </name>
+                     </p>
+                  </note>
                     </rdg>
             </app>
+            <ptr target="#textgrid:1234.7"/>
+            <ptr target="#textgrid:1234.7"/>
          </div>
+         <app>
+            <lem/>
+            <rdg wit="#d" type="pt">
+               <ref target="#gr_d_136_note1">
+                  <hi>*</hi>)</ref>
+            </rdg>
+         </app>
+         <app>
+            <lem/>
+            <rdg wit="#d" type="ptl">
+               <note place="bottom" type="authorial" xml:id="gr_d_136_note1">*) Von den eben so mannichfaltigen als
+                  großen <hi>Verdiensten</hi>
+                  <index indexName="persons">
+                     <term>Christus, s. Jesus Christus</term>
+                     <term>Jesus Christus</term>
+                  </index>Jesu um das menschliche Geschlecht müssen die Christen
+                  ausführlich und genau unterrichtet werden, und zwar nicht nur von
+                  denen, die er um uns durch sein Leiden und Sterben hat, sondern
+                  auch von denen, welche er durch sein ganzes Leben und durch die
+                  Führung seines Lehramts sich um uns erwarb. Durchgehends ist er
+                  als unser großer Wohlthäter, als der Gegenstand unsrer innigsten
+                  Liebe, Dankbarkeit und Verehrung, und, mit gehörigen
+                  Einschränkungen, als Muster der Nachahmung
+                  vorzustellen.</note>
+            </rdg>
+         </app>
+         <app>
+            <lem/>
+            <rdg type="ptl" wit="#c">
+               <div type="titlePage" xml:id="titlepage_2_1_c">
+                  <p>
+                     <hi rend="center-aligned">
+                        <pb edRef="#c" type="sp" n="1"/> Anweisung
+                        <lb/>zur <lb/>Bildung angehender Theologen. <lb/>Zweiter
+                        Theil.</hi>
+                  </p>
+               </div>
+               <pb edRef="#c" type="sp" n="2"/>
+            </rdg>
+         </app>
+         <choice resp="#uwes">
+            <sic>as</sic>
+            <corr>ds</corr>
+         </choice>
+         <choice resp="uwes">
+            <sic>as</sic>
+            <corr>ds</corr>
+         </choice>
       </body>
    </text>
 </TEI>
\ No newline at end of file
diff --git a/data/samples/rdg_om.xml b/data/samples/rdg_om.xml
new file mode 100644
index 0000000..05df0f1
--- /dev/null
+++ b/data/samples/rdg_om.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?><?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml"
+	schematypens="http://purl.oclc.org/dsdl/schematron"?>
+<TEI xmlns="http://www.tei-c.org/ns/1.0">
+   <text>
+        <p>
+          <app>
+               <lem>
+                    <seg type="item">
+                        <app>
+                        <lem/>
+                        <rdg wit="#c" type="pt">
+                                <milestone unit="p" edRef="#c" type="structure"/>
+                                <seg xml:id="var_1_51_p3_1">Unter den Neueren:</seg>
+                            </rdg>
+                     </app>
+                        <milestone unit="line" edRef="#c" type="structure"/>
+                        <seg xml:id="var_1_51_p3_item1">
+                            <index indexName="persons">
+                           <term>Mosheim, Johann Lorenz von</term>
+                        </index>
+                            <persName ref="#textgrid:250j4">
+                                <hi>Joh. Lorenz von</hi>
+                                <app>
+                              <lem>
+                                        <hi>Mosheims</hi>
+                                    </lem>
+                              <rdg wit="#c" type="v">
+                                        <hi>Mosheim</hi>
+                                    </rdg>
+                           </app>
+                            </persName> kurze Anweisung, die Gottesgelahrtheit vernünftig zu
+                        erlernen – – zum Druck befördert von <index indexName="persons">
+                           <term>Windheim, Christian Ernst von</term>
+                        </index>
+                            <hi>
+                                <persName ref="#textgrid:250j5">Christian Ernst von
+                              Windheim</persName>
+                            </hi>, Helmstädt 1756.<ptr target="#textgrid:250j7"/> in <choice>
+                           <abbr>gr.</abbr>
+                           <expan>groß</expan>
+                        </choice> 8.</seg>
+                    </seg>
+                </lem>
+               <rdg wit="#a" type="om"/>
+            </app>
+        </p>
+   </text>
+</TEI>
\ No newline at end of file
diff --git a/modules/intermediate_format/identification.xqm b/modules/intermediate_format/identification.xqm
index 0b43eda..3077446 100644
--- a/modules/intermediate_format/identification.xqm
+++ b/modules/intermediate_format/identification.xqm
@@ -120,7 +120,14 @@ declare function ident:left-branch-axis
                 
                 (: If tei:app has an empty tei:lem change the axis to tei:lems last child() :)
                 if ( empty($target/child::lem/node()) ) then (
-                    $target/child::rdg[@type eq "ppl" or @type eq "ptl"][1]/node()[1]
+                    if ( $target/child::rdg[@type eq "ppl" or @type eq "ptl"] ) then (
+                        $target/child::rdg[@type eq "ppl" or @type eq "ptl"][1]/node()[1]
+                    ) 
+                    
+                    else if ( $target/child::rdg[@type eq "pp" or @type eq "pt"] ) then (
+                        $target
+                    )
+                    else ()
                 ) 
                 
                 (: If tei:app has no empty tei:lem
diff --git a/oxygen/intermediate_format.oxygen.devel.xqm b/oxygen/intermediate_format.oxygen.devel.xqm
index 2b1a66a..1175e03 100644
--- a/oxygen/intermediate_format.oxygen.devel.xqm
+++ b/oxygen/intermediate_format.oxygen.devel.xqm
@@ -162,38 +162,48 @@ let $app-index := local:app-index( $pre//app[not(@type)] )
 let $target-index := target:index($app-index):)
 let $test := 
     <test>
-        <div>
-            <head>
-                <app>
-                    <lem>
-                        <app>
-                            <lem><aligned><hi>LEM Ãœberschrift</hi></aligned></lem>
-                            <rdg wit="#a" type="v">A Ãœberschrift</rdg>
-                        </app>
-                    </lem>
-                    <rdg wit="#a" type="v">überschrift</rdg>
-                </app>
-            </head>
-            <p>Erster Absatz</p>
-            <p>Zweiter Absatz</p>
-            <note>
-                <app>
-                    <lem>Anmerkung</lem>
-                    <rdg wit="#a" type="v">anmerkung</rdg>
-                    <rdg wit="#b" type="ppl"><div>DIV anmerkung</div></rdg>
-                    <rdg wit="#c" type="v"><div>DIV2 anmerkung</div></rdg>
-                </app>
-            </note>
-        </div>
+        <app>
+               <lem><item><app>
+                        <lem/>
+                        <rdg wit="#c" type="pt"><milestone unit="p" edRef="#c" type="structure"
+                              /><seg xml:id="var_1_51_p3_1">Unter den Neueren:</seg></rdg>
+                     </app><milestone unit="line" edRef="#c" type="structure"/><seg
+                        xml:id="var_1_51_p3_item1"><index indexName="persons">
+                           <term>Mosheim, Johann Lorenz von</term>
+                        </index><persName ref="#textgrid:250j4"><hi>Joh. Lorenz von</hi><app>
+                              <lem><hi>Mosheims</hi></lem>
+                              <rdg wit="#c" type="v"><hi>Mosheim</hi></rdg>
+                           </app></persName> kurze Anweisung, die Gottesgelahrtheit vernünftig zu
+                        erlernen – – zum Druck befördert von <index indexName="persons">
+                           <term>Windheim, Christian Ernst von</term>
+                        </index><hi><persName ref="#textgrid:250j5">Christian Ernst von
+                              Windheim</persName></hi>, Helmstädt 1756.<ptr target="#textgrid:250j7"
+                        /> in <choice>
+                           <abbr>gr.</abbr>
+                           <expan>groß</expan>
+                        </choice> 8.</seg></item></lem>
+               <rdg wit="#a" type="om"/>
+            </app>
     </test>
-    
+
+let $lem := $test/app/lem
 return (
     (:ident:left-nodes-path($test),:)
     (:test:branch-axis($test):)
-    test:reading-evaluation($test)
+    (:test:reading-evaluation($test):)
+    (:test:reading-evaluation($pre):)
     (:test:identify-target($test):)
+    (:test:branch-axis($test):)
+
+    
+    (:test:reading-evaluation($pre):)
+    
+    (:ident:left-branch-axis($lem):)
+    (:ident:first-save-node($lem):)
+    (:ident:walk($test, ()):)
+    
     (:$pre:)
-    (:ident:walk($pre, ()):)
+    ident:walk($pre, ())
 (:    $target-index:)
     (:local:target-in-index("d0t36", $app-index),:)
     (:target:conversion-by-target-index($pre, $target-index):)
diff --git a/repo.xml b/repo.xml
index a1e2fd9..c5a0366 100644
--- a/repo.xml
+++ b/repo.xml
@@ -10,4 +10,5 @@
     <target>interformat</target>
     <prepare>pre-install.xql</prepare>
     <finish/>
+<deployed>2018-03-26T10:38:10.685+02:00</deployed>
 </meta>
\ No newline at end of file
diff --git a/rest/test/interform.test.xql b/rest/test/interform.test.xql
index 3849ac3..6416b4d 100644
--- a/rest/test/interform.test.xql
+++ b/rest/test/interform.test.xql
@@ -1,16 +1,15 @@
 xquery version "3.1";
 
 declare namespace tei = "http://www.tei-c.org/ns/1.0";
-import module namespace functx="http://www.functx.com";
-import module namespace pre="http://bdn.edition.de/intermediate_format/preprocessing" at "xmldb:exist:///db/apps/interformat/modules/intermediate_format/preprocessing.xqm";
-import module namespace ident = "http://bdn.edition.de/intermediate_format/identification" at "xmldb:exist:///db/apps/interformat/modules/intermediate_format/identification.xqm";
+import module namespace pre="http://bdn-edition.de/intermediate_format/preprocessing" at "xmldb:exist:///db/apps/interformat/modules/intermediate_format/preprocessing.xqm";
+import module namespace ident = "http://bdn-edition.de/intermediate_format/identification" at "xmldb:exist:///db/apps/interformat/modules/intermediate_format/identification.xqm";
 
 
 declare option exist:serialize "method=xml media-type=text/xml omit-xml-declaration=no indent=no";
 
 (: http://localhost:8080/exist/rest/apps/interformat/rest/intermediate_format.xql :)
 (:declare variable $doc-path := request:get-parameter("path", ());    :)
-declare variable $doc-path := "/apps/interformat/data/samples/samples4.xml";
+declare variable $doc-path := "/apps/interformat/data/samples/rdg_om.xml";
 let $doc := doc($doc-path)
 let $preprocessed-data := pre:preprocessing($doc/tei:TEI)
 return (
-- 
GitLab