Skip to content
Snippets Groups Projects
Commit da5bcd3d authored by Michelle Weidling's avatar Michelle Weidling :blowfish:
Browse files

Merge branch 'release/1.0.0'

parents e578ced2 c9b6571a
No related branches found
No related tags found
No related merge requests found
project.name=http://bdn-edition.de/intermediate_format
project.name=http://bdn-edition.de/intermediate_format-develop
project.version=1.0.0
project.title=BdN Intermediate Format
project.abbrev=interformat-develop
......
(:~
(:~
: ifweb.xql offers a simple interface for creating the website specific BdN
: intermediate format of a given resource.
:
:
: @author Michelle Rodzis
: @version 1.0
:
:
:)
xquery version "3.1";
......@@ -24,17 +24,17 @@ declare variable $ifweb:replace-whitespace := true();
declare function ifweb:main($resource as xs:string) as xs:string? {
let $doc := doc($config:sade-data || $resource)
let $filename := substring-before($resource, '.xml') || "-if.xml"
return ifweb:transform($doc, $filename)
};
declare function ifweb:transform($doc as node()*, $filename as xs:string)
declare function ifweb:transform($doc as node()*, $filename as xs:string)
as node()* {
let $preprocessed-data := pre:preprocessing($doc/tei:TEI, $ifweb:replace-whitespace)
let $intermediate-format := ident:walk($preprocessed-data, ())
let $store := xmldb:store($config:sade-data, $filename, $intermediate-format)
return $intermediate-format
};
......@@ -44,12 +44,12 @@ $target-dir as xs:string) as node()* {
let $preprocessed-data := pre:preprocessing($doc/tei:TEI, $ifweb:replace-whitespace)
let $intermediate-format := ident:walk($preprocessed-data, ())
let $store := xmldb:store($target-dir, $filename, $intermediate-format)
return $intermediate-format
};
declare function ifweb:complete-xml($author as xs:string, $xml as node()*)
declare function ifweb:complete-xml($author as xs:string, $xml as node()*)
as node()* {
let $filename := $author || "-full-if.xml"
return ifweb:transform($xml, $filename)
......@@ -61,17 +61,32 @@ $target-dir as xs:string) as node()* {
return ifweb:transform($resource, $filename, $target-dir)
};
declare function ifweb:transform-split-xml($xml as node()*, $filename as xs:string,
declare function ifweb:transform-split-xml($xml as node()*, $filename as xs:string,
$dir as xs:string) {
let $preprocessed-data := pre:preprocessing($xml/*, $ifweb:replace-whitespace)
let $intermediate-format := ident:walk($preprocessed-data, ())
let $content :=
element tei:div {
(: sometimes we have structural variance on chapter level - in these cases
tei:app is the root element of $xml, not tei:div. for the HTML serialization
of the structural variance to function properly we have to preserve the
tei:app :)
let $content :=
if($xml[self::tei:app]) then
element tei:app {
$xml/@*,
attribute id {generate-id($xml)},
$intermediate-format
}
let $store := xmldb:store($dir, $filename, $content)
else
($xml/@*,
attribute id {generate-id($xml)},
$intermediate-format)
let $transformed :=
element tei:div {
$content
}
let $store := xmldb:store($dir, $filename, $transformed)
return $intermediate-format
};
......@@ -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 (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment