diff --git a/CHANGELOG.md b/CHANGELOG.md index b5e85d3..f779242 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,26 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +## [0.5.0] - 2020-01-01 +### Added +* [tei.xquery] +* `mvc:minify` ([mvc.xquery]) +* `mvc-tei:dispatch` ([tei.xquery]) +* `mvc-tei:passthru` ([tei.xquery]) +* `mvc-tei:w` ([tei.xquery]) +* `mvc-tei:s` ([tei.xquery]) +* `mvc-tei:seg` ([tei.xquery]) +* `mvc-tei:p` ([tei.xquery]) +* `mvc-tei:bibl` ([tei.xquery]) +* `mvc-tei:ref` ([tei.xquery]) +* `mvc-tei:quote` ([tei.xquery]) +* `mvc-tei:q` ([tei.xquery]) +* `mvc-tei:hi` ([tei.xquery]) +* `mvc-tei:mark` ([tei.xquery]) +* `mvc-tei:pb` ([tei.xquery]) +* `mvc-tei:lb` ([tei.xquery]) +* `mvc-tei:body` ([tei.xquery]) + ## [0.4.0] - 2019-03-25 ### Added * [mvc.xquery] @@ -142,7 +162,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p * [LISENCE] * [README.md] -[Unreleased]: https://github.com/AdamSteffanick/mvc-xquery/compare/v0.4.0...HEAD +[Unreleased]: https://github.com/AdamSteffanick/mvc-xquery/compare/v0.5.0...HEAD +[0.5.0]: https://github.com/AdamSteffanick/mvc-xquery/compare/v0.4.0...v0.5.0 [0.4.0]: https://github.com/AdamSteffanick/mvc-xquery/compare/v0.3.0...v0.4.0 [0.3.0]: https://github.com/AdamSteffanick/mvc-xquery/compare/v0.2.3...v0.3.0 [0.2.3]: https://github.com/AdamSteffanick/mvc-xquery/compare/v0.2.2...v0.2.3 @@ -167,6 +188,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p [bootstrap.xquery]: ./modules/bootstrap.xquery [html5.xquery]: ./modules/html5.xquery [mvc.xquery]: ./modules/mvc.xquery +[tei.xquery]: ./modules/tei.xquery [Bootstrap]: https://getbootstrap.com/ [shields.io]: http://shields.io/ \ No newline at end of file diff --git a/README.md b/README.md index b2d3280..7711d21 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ MVC-XQuery | A Model-View-Controller framework in XQuery for BaseX -Copyright (C) 2018–2019 [Adam Steffanick](https://www.steffanick.com/adam/) +Copyright (C) 2018–2020 [Adam Steffanick](https://www.steffanick.com/adam/) ## Download * [**Latest release**](https://github.com/AdamSteffanick/mvc-xquery/releases/latest) @@ -52,6 +52,7 @@ Copyright (C) 2018–2019 [Adam Steffanick](https://www.steffanick.com/adam/) * [BaseX] 9.1.2 support * [Bootstrap] v4.3.1 support * [HTML5] v5.2 support +* [TEI] P5 support ## Manifest tree MVC-XQuery should contain: @@ -67,11 +68,15 @@ mvc-xquery │   ├── bootstrap.xquery │   ├── html5.xquery │   └── mvc.xquery +│   └── tei.xquery └── view.xquery -1 directory, 9 files +1 directory, 10 files ``` +## Acknowledgments +MVC-XQuery derives from [Experiments with XQuery, RESTXQ, and MVC in BaseX](https://gist.github.com/CliffordAnderson/80c68ea43557446b8331) by [Clifford Anderson](https://github.com/CliffordAnderson) and my work with the members of the TEI, XQuery, Semantic Web, and Linked Data working groups at Vanderbilt University. + ## License This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. @@ -80,7 +85,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY You should have received a copy of the GNU General Public License along with this program. If not, see . [CHANGELOG]: ./CHANGELOG.md -[version-badge]: https://img.shields.io/badge/mvc--xquery-v0.4.0-0038e2.svg?style=flat-square +[version-badge]: https://img.shields.io/badge/mvc--xquery-v0.5.0-0038e2.svg?style=flat-square [LICENSE]: ./LICENSE [license-badge]: https://img.shields.io/badge/license-GPL-0038e2.svg?style=flat-square @@ -90,4 +95,5 @@ You should have received a copy of the GNU General Public License along with thi [BaseX]: http://basex.org/ [Bootstrap]: https://getbootstrap.com/ -[HTML5]: https://www.w3.org/TR/html52/ \ No newline at end of file +[HTML5]: https://www.w3.org/TR/html52/ +[TEI]: https://tei-c.org/guidelines/p5/ \ No newline at end of file diff --git a/controller.xquery b/controller.xquery index 563b0a3..c81dfb1 100644 --- a/controller.xquery +++ b/controller.xquery @@ -4,13 +4,13 @@ xquery version "3.1" encoding "UTF-8"; : The MVC-XQuery controller function library module. : : MVC-XQuery | A Model-View-Controller framework in XQuery for BaseX - : Copyright (C) 2018–2019 Adam Steffanick + : Copyright (C) 2018–2020 Adam Steffanick : : @author Adam Steffanick : @see https://www.steffanick.com/adam/ - : @version v0.4.0 + : @version v0.5.0 : @see https://github.com/AdamSteffanick/mvc-xquery - : March 25, 2019 + : January 1, 2020 : @since v0.0.2 : : This program is free software: you can redistribute it and/or modify diff --git a/model.xquery b/model.xquery index 8e24f2a..2becffb 100644 --- a/model.xquery +++ b/model.xquery @@ -4,13 +4,13 @@ xquery version "3.1" encoding "UTF-8"; : The MVC-XQuery model function library module. : : MVC-XQuery | A Model-View-Controller framework in XQuery for BaseX - : Copyright (C) 2018–2019 Adam Steffanick + : Copyright (C) 2018–2020 Adam Steffanick : : @author Adam Steffanick : @see https://www.steffanick.com/adam/ - : @version v0.4.0 + : @version v0.5.0 : @see https://github.com/AdamSteffanick/mvc-xquery - : March 25, 2019 + : January 1, 2020 : @since v0.0.2 : : This program is free software: you can redistribute it and/or modify diff --git a/modules/bootstrap.xquery b/modules/bootstrap.xquery index 23b78df..db1b3ba 100644 --- a/modules/bootstrap.xquery +++ b/modules/bootstrap.xquery @@ -1,16 +1,16 @@ xquery version "3.1" encoding "UTF-8"; (:~ - : The MVC-XQuery Bootstrap v4.2.1 function library module. + : The MVC-XQuery Bootstrap v4.3.1 function library module. : : MVC-XQuery | A Model-View-Controller framework in XQuery for BaseX - : Copyright (C) 2018–2019 Adam Steffanick + : Copyright (C) 2018–2020 Adam Steffanick : : @author Adam Steffanick : @see https://www.steffanick.com/adam/ - : @version v0.4.0 + : @version v0.5.0 : @see https://github.com/AdamSteffanick/mvc-xquery - : March 25, 2019 + : January 1, 2020 : @since v0.2.0 : : This program is free software: you can redistribute it and/or modify diff --git a/modules/html5.xquery b/modules/html5.xquery index f1f419b..e54f17e 100644 --- a/modules/html5.xquery +++ b/modules/html5.xquery @@ -4,13 +4,13 @@ xquery version "3.1" encoding "UTF-8"; : The MVC-XQuery HTML v5.2 function library module. : : MVC-XQuery | A Model-View-Controller framework in XQuery for BaseX - : Copyright (C) 2018–2019 Adam Steffanick + : Copyright (C) 2018–2020 Adam Steffanick : : @author Adam Steffanick : @see https://www.steffanick.com/adam/ - : @version v0.4.0 + : @version v0.5.0 : @see https://github.com/AdamSteffanick/mvc-xquery - : March 25, 2019 + : January 1, 2020 : @since v0.3.0 : : This program is free software: you can redistribute it and/or modify diff --git a/modules/mvc.xquery b/modules/mvc.xquery index 04fd290..dab187a 100644 --- a/modules/mvc.xquery +++ b/modules/mvc.xquery @@ -4,13 +4,13 @@ xquery version "3.1" encoding "UTF-8"; : The MVC-XQuery function library module. : : MVC-XQuery | A Model-View-Controller framework in XQuery for BaseX - : Copyright (C) 2018–2019 Adam Steffanick + : Copyright (C) 2018–2020 Adam Steffanick : : @author Adam Steffanick : @see https://www.steffanick.com/adam/ - : @version v0.4.0 + : @version v0.5.0 : @see https://github.com/AdamSteffanick/mvc-xquery - : March 25, 2019 + : January 1, 2020 : @since v0.4.0 : : This program is free software: you can redistribute it and/or modify @@ -34,19 +34,20 @@ module namespace mvc = "mvc"; (: required function library modules :) import module namespace bootstrap = "bootstrap" at "bootstrap.xquery"; import module namespace html5 = "html5" at "html5.xquery"; +import module namespace mvc-tei = "mvc-tei" at "tei.xquery"; (:~ : A public variable containing the MVC-XQuery version. : : @author Adam Steffanick : @see https://www.steffanick.com/adam/ - : @version v1.0.0 + : @version v1.0.1 : @since v0.4.0 : : @return one string containing the MVC-XQuery brand :) declare %public variable $mvc:version as xs:string := ( - "v0.4.0" + "v0.5.0" ); (:~ @@ -377,3 +378,33 @@ declare %public function mvc:html-refine( $refined-input ) }; + +(:~ + : A public function to minify the HTML5 output of ft:mark() for BaseX. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $parameter is a sequence of zero or more nodes + : @return one minified node + :) +declare %public function mvc:minify($parameter as node()*) { + let $serialization-parameters := + + + + let $codeString := fn:serialize($parameter, $serialization-parameters) + +(: let $codeStringNormalized := fn:replace($codeString, "\s+", " ") :) + let $codeStringMinifyElementWhitespace := fn:replace($codeString, " \s+", " ") +(: let $codeStringMinifyElementWhitespace2 := fn:replace($codeString, ">\s+<", "><") :) + let $codeStringMinifyCloseSpans := fn:replace($codeStringMinifyElementWhitespace, "\s+", "") + let $codeStringMinifyCloseMarkLF := fn:replace($codeStringMinifyCloseSpans, " ", "") + let $codeStringMinifyLFCloseI := fn:replace($codeStringMinifyCloseMarkLF, " ", "") + let $codeStringMinifyQuoteLF := fn:replace($codeStringMinifyLFCloseI, "“ ", "“") + let $codeStringMinifyLFQuote := fn:replace($codeStringMinifyQuoteLF, " ”", "”") + + return fn:parse-xml-fragment($codeStringMinifyLFQuote) +}; diff --git a/modules/tei.xquery b/modules/tei.xquery new file mode 100644 index 0000000..7c12723 --- /dev/null +++ b/modules/tei.xquery @@ -0,0 +1,299 @@ +xquery version "3.1" encoding "UTF-8"; + +(:~ + : The MVC-XQuery TEI function library module. + : + : MVC-XQuery | A Model-View-Controller framework in XQuery for BaseX + : Copyright (C) 2018–2020 Adam Steffanick + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v0.5.0 + : @see https://github.com/AdamSteffanick/mvc-xquery + : January 1, 2020 + : @since v0.5.0 + : + : This program is free software: you can redistribute it and/or modify + : it under the terms of the GNU General Public License as published by + : the Free Software Foundation, either version 3 of the License, or + : (at your option) any later version. + : + : This program is distributed in the hope that it will be useful, + : but WITHOUT ANY WARRANTY; without even the implied warranty of + : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + : GNU General Public License for more details. + : + : You should have received a copy of the GNU General Public License + : along with this program. If not, see . + : + : LICENSE: GNU General Public License + : @see: https://github.com/AdamSteffanick/mvc-xquery/blob/master/LICENSE + :) +module namespace mvc-tei = "mvc-tei"; + +(: required function library modules :) +import module namespace mvc = "mvc" at "mvc.xquery"; + +(: required namespace declaration :) +declare namespace tei = "http://www.tei-c.org/ns/1.0"; + +(:~ + : A public function to convert TEI to HTML. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $nodes is a sequence of zero or more TEI nodes + : @return one HTML node + :) +declare function mvc-tei:dispatch($nodes as node()*) { + for $node in $nodes + return + mvc:minify( + typeswitch($node) + case text() return $node (: mvc-tei:mvc-tei-text($node) :) + case comment() return $node + case element(tei:w) return mvc-tei:w($node) + case element(tei:s) return mvc-tei:s($node) + case element(tei:seg) return mvc-tei:seg($node) + case element(tei:p) return mvc-tei:p($node) + case element(tei:bibl) return mvc-tei:bibl($node) + case element(tei:ref) return mvc-tei:ref($node) + case element(tei:quote) return mvc-tei:quote($node) + case element(tei:q) return mvc-tei:q($node) + case element(tei:hi) return mvc-tei:hi($node) + case element(tei:mark) return mvc-tei:mark($node) + case element(tei:pb) return mvc-tei:pb($node) + case element(tei:lb) return mvc-tei:lb($node) + case element(tei:body) return mvc-tei:body($node) + default return mvc-tei:passthru($node) + ) +}; + +(:~ + : A private function to recurse through child nodes for mvc-tei:dispatch(). + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is a sequence of zero or more TEI nodes + : @return one HTML node + :) +declare %private function mvc-tei:passthru($node as node()*) as item()* { + element {name($node)} {($node/@*, mvc-tei:dispatch($node/node()))} +}; + +(:~ + : A private function to convert to with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:w element + : @return one span element with attributes + :) +declare %private function mvc-tei:w($node as element(tei:w)) as element() { + let $lemmaRef := $node/@lemmaRef + return + {mvc-tei:dispatch($node/node())} +}; + +(:~ + : A private function to convert to with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:s element + : @return one span element with attributes + :) +declare %private function mvc-tei:s($node as element(tei:s)) as element() { + let $sentence := $node/@n + return + {mvc-tei:dispatch($node/node())} +}; + +(:~ + : A private function to convert to with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:seg element + : @return one span element with attributes + :) +declare %private function mvc-tei:seg($node as element(tei:seg)) as element() { + let $type := $node/@type + return + {mvc-tei:dispatch($node/node())} +}; + +(:~ + : A private function to convert

to

with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:p element + : @return one p element with attributes + :) +declare %private function mvc-tei:p($node as element(tei:p)) as element() { +

{mvc-tei:dispatch($node/node())}

+}; + +(:~ + : A private function to convert to with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:bibl element + : @return one span element with attributes + :) +declare %private function mvc-tei:bibl($node as element(tei:bibl)) as element() { + {mvc-tei:dispatch($node/node())} +}; + +(:~ + : A private function to convert to with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:ref element + : @return one span element with attributes + :) +declare %private function mvc-tei:ref($node as element(tei:ref)) as element() { + {mvc-tei:dispatch($node/node())} +}; + +(:~ + : A private function to convert to
or with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:quote element + : @return one blockquote or span element with attributes + :) +declare %private function mvc-tei:quote($node as element(tei:quote)) as element() { + let $rend := $node/@rend + return + if ($rend = 'blockquote') then +
{mvc-tei:dispatch($node/node())}
+ else + “{mvc-tei:dispatch($node/node())}” +}; + +(:~ + : A private function to convert to with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:q element + : @return one span element with attributes + :) +declare %private function mvc-tei:q($node as element(tei:q)) as element() { + “{mvc-tei:dispatch($node/node())}” +}; + +(:~ + : A private function to convert to or with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:hi element + : @return one i or span element with attributes + :) +declare %private function mvc-tei:hi($node as element(tei:hi)) as element() { + let $rend := $node/@rend + return + if ($rend = 'italic') then + {mvc-tei:dispatch($node/node())} + else + {mvc-tei:dispatch($node/node())} +}; + +(:~ + : A private function to convert to with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:mark element + : @return one mark element with attributes + :) +declare %private function mvc-tei:mark($node as element(tei:mark)) as element() { + {mvc-tei:dispatch($node/node())} +}; + +(:~ + : A private function to convert to with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:pb element + : @return one span element with attributes + :) +declare %private function mvc-tei:pb($node as element(tei:pb)) { + +}; + +(:~ + : A private function to convert to
. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:lb element + : @return one span br with attributes + :) +declare %private function mvc-tei:lb($node as element(tei:lb)) as element() { +
+}; + +(:~ + : A private function to convert to
with attributes. + : + : @author Adam Steffanick + : @see https://www.steffanick.com/adam/ + : @version v1.0.0 + : @since v0.5.0 + : + : @param $node is one tei:body element + : @return one span element with attributes + :) +declare %private function mvc-tei:body($node as element(tei:body)) as element() { +
{mvc-tei:dispatch($node/node())}
+}; diff --git a/view.xquery b/view.xquery index 80048a0..33bb3f4 100644 --- a/view.xquery +++ b/view.xquery @@ -4,13 +4,13 @@ xquery version "3.1" encoding "UTF-8"; : The MVC-XQuery view function library module. : : MVC-XQuery | A Model-View-Controller framework in XQuery for BaseX - : Copyright (C) 2018–2019 Adam Steffanick + : Copyright (C) 2018–2020 Adam Steffanick : : @author Adam Steffanick : @see https://www.steffanick.com/adam/ - : @version v0.4.0 + : @version v0.5.0 : @see https://github.com/AdamSteffanick/mvc-xquery - : March 25, 2019 + : January 1, 2020 : @since v0.0.2 : : This program is free software: you can redistribute it and/or modify