From 0b861542f3b5e5ae9477818314cdb9fe33aff98a Mon Sep 17 00:00:00 2001
From: mrodzis <weidling@sub.uni-goettingen.de>
Date: Tue, 29 Jan 2019 08:43:09 +0100
Subject: [PATCH] Place editorial comments in separate element

Although we once changed this and placed the comments right where there are
encoded, this leads to problems with the blocklevel element processing in the
digital view of the website: rdgMarkers seem to disappear because they are
sorted into the editorial comments.

Therefore we decided to revert the changes once made. This will have to be
considered for the print edition also.
---
 modules/intermediate_format/preprocessing.xqm | 26 +++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/modules/intermediate_format/preprocessing.xqm b/modules/intermediate_format/preprocessing.xqm
index c6a6fb9..54c89ac 100644
--- a/modules/intermediate_format/preprocessing.xqm
+++ b/modules/intermediate_format/preprocessing.xqm
@@ -51,7 +51,9 @@ declare function pre:preprocessing-textNode
                 element{$node/name()}{
                     $node/@*,
                     pre:preprocessing-textNode($node/node()),
-                    element{"editorial-notes"}{}
+                    element{"editorial-notes"}{
+                        $node//note[@type eq "editorial-commentary"]
+                    }
                 }
             )
 
@@ -141,7 +143,7 @@ declare function pre:default-element
  : @author Uwe Sikora
  :)
 declare function pre:preprocessing
-    ($nodes as node()*, $replace-whitespace as xs:boolean) 
+    ($nodes as node()*, $replace-whitespace as xs:boolean)
     as item()* {
 
     for $node in $nodes
@@ -164,7 +166,11 @@ declare function pre:preprocessing
                 element{$node/name()}{
                     $node/@*,
                     pre:preprocessing($node/node(), $replace-whitespace),
-                    element{"editorial-notes"}{}
+                    element{"editorial-notes"}{
+                        for $editorial-note in $node//note[@type eq "editorial-commentary"]
+                        return
+                            pre:default-element( $editorial-note, pre:preprocessing($editorial-note/node(), $replace-whitespace) )
+                    }
                 }
             )
 
@@ -179,26 +185,26 @@ declare function pre:preprocessing
                         $node/@*,
                         attribute id {generate-id($node)},
                         pre:preprocessing($node/node(), $replace-whitespace)
-                    } 
+                    }
                 else if ($node[not(@type)][not(descendant::div)]) then
                     element{$node/name()}{
                         attribute type {"single-div"},
                         attribute id {generate-id($node)},
                         pre:preprocessing($node/node(), $replace-whitespace)
-                    }  
+                    }
                 else (
                     pre:default-element( $node, pre:preprocessing($node/node(), $replace-whitespace) )
                 )
 
             )
-            
+
             case element(app) return
                 if($node/parent::div[@type = "section-group"]) then
                     element{$node/name()}{
                         attribute type {"standalone"},
                         attribute id {generate-id($node)},
                         pre:preprocessing($node/node(), $replace-whitespace)
-                    }  
+                    }
                 else
                     pre:default-element( $node, pre:preprocessing($node/node(), $replace-whitespace) )
 
@@ -219,7 +225,11 @@ declare function pre:preprocessing
             )
 
             case element(note) return (
-                pre:default-element( $node, pre:preprocessing($node/node(), $replace-whitespace) )
+                if ( $node[@type != "editorial-commentary"] or $node[ not(@type) ] ) then (
+                    pre:default-element( $node, pre:preprocessing($node/node(), $replace-whitespace) )
+                ) else ( )
+
+(:                pre:default-element( $node, pre:preprocessing($node/node(), $replace-whitespace) ):)
             )
 
             case element(pb) return (
-- 
GitLab