diff --git a/oxygen/devel/modules/unittesting.xqm b/oxygen/devel/modules/unittesting.xqm new file mode 100644 index 0000000000000000000000000000000000000000..8b06fdfd9822d84387c0d4a201e19e6445034a0e --- /dev/null +++ b/oxygen/devel/modules/unittesting.xqm @@ -0,0 +1,100 @@ +xquery version "3.0"; +(:~ + : UNIT TESTING Module ("test", "http://bdn.edition.de/intermediate_format/unit_testing") + : ******************************************************************************************* + : This module defines functions to test different functions from the Intermediate Format conversion + : + : It includes the main module "ident" + : + : @version 1.0 (2018-02-05) + : @status development + : @author Uwe Sikora + :) +module namespace test="http://bdn.edition.de/intermediate_format/unit_testing"; + +import module namespace ident = "http://bdn.edition.de/intermediate_format/identification" at "../../../modules/intermediate_format/identification.xqm"; + +(:############################# Modules Functions #############################:) + +(:~ + : test:branch-axis() + : This function evaluates the left- and right-branch AXIS + : + : @param $node the nodes to evaluate the left- and right-branch AXIS for + : @return evaluation-report as item() + : + : @version 1.0 (2018-02-05) + : @status development (working) + : @author Uwe Sikora + :) +declare function test:branch-axis + ( $node as node() ) as item() { + let $left-axis := ident:left-branch-axis($node) + let $right-axis := ident:right-branch-axis($node) + return + element {"axisTest"}{ + element {"targetNode"}{$node}, + element {"axis"}{ + element {"leftAxis"}{ + attribute {"names"}{$left-axis/name()}, + for $item at $nr in $left-axis + return + element {"item"}{ + attribute {"n"}{$nr}, + attribute {"gid"}{generate-id($item)}, + $item + } + }, + element {"rightAxis"}{ + attribute {"names"}{$right-axis/name()}, + for $item at $nr in $right-axis + return + element {"item"}{ + attribute {"n"}{$nr}, + attribute {"gid"}{generate-id($item)}, + $item + } + } + } + } +}; + + +(:~ + : test:reading-evaluation() + : This function evaluates tei:lem and tei:app elements. It identifies the save first + : and last node and collects readingMarkers + : + : @param $reading the reading to be tested + : @return evaluation-report as item() + : + : @version 1.0 (2018-02-05) + : @status development (working) + : @author Uwe Sikora + :) +declare function test:reading-evaluation + ( $readings as node()* ) as item()* { + + for $reading at $nr in $readings + let $first-save-node := ident:first-save-node($reading) + let $last-save-node := ident:last-save-node($reading) + return + element {$reading/name()}{ + $reading/@*, + attribute {"index"} { $nr }, + element {"self"}{ + attribute {"gid"}{ generate-id($reading) }, + $reading + }, + element {"target"}{ + attribute {"type"}{ "open" }, + attribute {"gid"}{ generate-id($first-save-node) }, + $first-save-node + }, + element {"target"}{ + attribute {"type"}{ "close" }, + attribute {"gid"}{ generate-id($last-save-node) }, + $last-save-node + } + } +}; \ No newline at end of file diff --git a/oxygen/intermediate_format.oxygen.devel.xqm b/oxygen/intermediate_format.oxygen.devel.xqm index 6098303eb495b5f78c2b3b4c25f8691ba5e9b763..c51fc57826c9cf99d5acb61d72b05e633c96a592 100644 --- a/oxygen/intermediate_format.oxygen.devel.xqm +++ b/oxygen/intermediate_format.oxygen.devel.xqm @@ -7,7 +7,7 @@ import module namespace functx = "http://www.functx.com" at "functx.xqm"; import module namespace markerset = "http://bdn.edition.de/intermediate_format/markerset" at "../modules/intermediate_format/markerset.xqm"; import module namespace pre = "http://bdn.edition.de/intermediate_format/preprocessing" at "../modules/intermediate_format/preprocessing.xqm"; import module namespace ident = "http://bdn.edition.de/intermediate_format/identification" at "../modules/intermediate_format/identification.xqm"; - +import module namespace test = "http://bdn.edition.de/intermediate_format/unit_testing" at "devel/modules/unittesting.xqm"; (:declare namespace target = "http://www.interform.com/target_index"; import module "http://www.interform.com/target_index" at "targetindex.xqm"; :) @@ -17,18 +17,6 @@ declare namespace tei = "http://www.tei-c.org/ns/1.0"; (:declare option saxon:output "indent=no";:) -declare variable $apparatus := ('app'); -declare variable $apparatus-childs := ('lem', 'rdg'); -declare variable $blocklevel-elements := ('titlePage', 'titlePart', 'aligned', 'div', 'list', 'item', 'table', 'row', 'cell', 'head', 'p', 'note'); - - -declare function local:in-sequence - ( $values as xs:anyAtomicType* , $sequence as xs:anyAtomicType* ) as xs:boolean { - - $values = $sequence -}; - - declare function local:app-index ( $apps as node()* ) as item()* { @@ -153,8 +141,8 @@ declare function local:check-reading declare function local:is-save-first-node ($node as node()) as xs:boolean { let $first-descendants := local:first-descendants($node) - let $has-save-first-descendants := not ( local:in-sequence($first-descendants/name(), $blocklevel-elements) ) - let $self-ble := functx:is-value-in-sequence( $node/name(), $blocklevel-elements ) + let $has-save-first-descendants := not ( ident:in-sequence($first-descendants/name(), $ident:blocklevel-elements) ) + let $self-ble := functx:is-value-in-sequence( $node/name(), $ident:blocklevel-elements ) return if ($has-save-first-descendants and not ($self-ble)) then (true()) else (false()) }; @@ -162,46 +150,12 @@ declare function local:is-save-first-node declare function local:is-save-last-node ($node as node()) as xs:boolean { let $last-descendants := local:last-descendants($node) - let $has-save-last-descendants := not ( local:in-sequence($last-descendants/name(), $blocklevel-elements) ) - let $self-ble := functx:is-value-in-sequence( $node/name(), $blocklevel-elements ) + let $has-save-last-descendants := not ( ident:in-sequence($last-descendants/name(), $ident:blocklevel-elements) ) + let $self-ble := functx:is-value-in-sequence( $node/name(), $ident:blocklevel-elements ) return if ($has-save-last-descendants and not ($self-ble)) then (true()) else (false()) }; -declare function local:axis-test - ( $node as node() ) as item() { - let $left-axis := ident:left-branch-axis($node) - let $right-axis := ident:right-branch-axis($node) - return - element {"axisTest"}{ - element {"node"}{$node}, - (:element {"test"}{ - attribute {"index"}{fn:index-of($left-axis, $left-axis[4])}, - fn:index-of($left-axis, $left-axis[ ident:is-or-are-ble(self::node()/name()) ][last()]) - },:) - element {"leftAxis"}{ - attribute {"names"}{$left-axis/name()}, - for $item at $nr in $left-axis - return - element {"item"}{ - attribute {"n"}{$nr}, - attribute {"gid"}{generate-id($item)}, - $item - } - }, - element {"rightAxis"}{ - attribute {"names"}{$right-axis/name()}, - for $item at $nr in $right-axis - return - element {"item"}{ - attribute {"n"}{$nr}, - attribute {"gid"}{generate-id($item)}, - $item - } - } - } -}; - let $doc := . let $pre := pre:preprocessing($doc/node()) @@ -230,10 +184,10 @@ let $test := <test> </test> return ( (:ident:left-nodes-path($test),:) - (:local:axis-test($test):) + test:branch-axis($test) (:ident:identify-unit-test($pre):) (:$pre:) - ident:walk($pre, ()) + (:ident:walk($pre, ()):) (: $target-index:) (:local:target-in-index("d0t36", $app-index),:) (:target:conversion-by-target-index($pre, $target-index):)