Skip to content

Commit

Permalink
add <sup> for additional-verses
Browse files Browse the repository at this point in the history
  • Loading branch information
flicksolutions committed Feb 17, 2025
1 parent 29af281 commit 6f864c2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/teipb/odd/parzival-verse.odd
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
<model behaviour="block" cssClass="line" useSourceRendition="true">
<param name="id" value="substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' ')"/>
<param name="content" value="."/>
<param name="verse" value="concat(substring-before(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),'.'),'.',number(substring-after(if (@xml:id) then @xml:id else @n, '.')))"/>
<pb:template xmlns="" xml:space="preserve"><span class="verse" data-verse="[[id]]">[[verse]]</span><span class="content">[[content]]</span></pb:template>
<param name="verse" value="let $verse := substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' ') let $afterDot := substring-after($verse, '.') let $beforeDash := if (contains($afterDot, '-')) then substring-before($afterDot, '-') else $afterDot return concat( substring-before($verse, '.'), '.', number($beforeDash) )"/>

This comment has been minimized.

Copy link
@pdaengeli

pdaengeli Feb 17, 2025

Collaborator

Good change, much more readable than before.

This might also work (a bit shorter and, depending on familiarity with the idioms, clearer):

let $verse := (@xml:id,@n)[1] => substring-after(if (@xml:id) then '_' else ' ')
let $afterDot := $verse => substring-after('.') 
let $beforeDash := $afterDot => tokenize('-') => head()  
return $verse => substring-before('.') ||  '.' || $beforeDash => number()

This comment has been minimized.

Copy link
@flicksolutions

flicksolutions Feb 18, 2025

Author Member

ChatGPT takes about 70% of the credit here ;-)

  • but thanks!
    I'll introduce the shorter version. thanks!

This comment has been minimized.

Copy link
@pdaengeli

pdaengeli Feb 18, 2025

Collaborator

Mind you, it's untested.

This comment has been minimized.

Copy link
@flicksolutions

flicksolutions Feb 18, 2025

Author Member

I'm getting this error as a response when putting that in the ODD:

It is a dynamic error if evaluation of an expression relies on some part of the dynamic context that has not been assigned a value. Error while evaluating expression: import module namespace m='http://www.tei-c.org/pm/models/parzival-verse/web' at 'parzival-verse-web.xql';\n\ndeclare variable $xml external;\n\ndeclare variable $parameters external;\n\nlet $options := map {\n "styles": ["transform/parzival-verse.css"],\n "collection": "/db/apps/parzival/transform",\n "parameters": if (exists($parameters)) then $parameters else map {}\n}\nreturn m:transform($options, $xml). Undefined context sequence for 'attribute::xml:id' [at line 128 column 9 in module /db/apps/parzival/transform/parzival-verse-web.xql]

So I think we'll keep it at what we have for now :)

This comment has been minimized.

Copy link
@pdaengeli

pdaengeli Feb 18, 2025

Collaborator

sure, relying on eXist/TEIPb for extensive XPath coverage was a risky bet :P

<param name="afterDash" value="let $afterDot := substring-after(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '), '.') return if (contains($afterDot, '-')) then substring-after($afterDot, '-') else ''"/>
<pb:template xmlns="" xml:space="preserve"><span class="verse" data-verse="[[id]]">[[verse]]<sup>[[afterDash]]</sup></span><span class="content">[[content]]</span></pb:template>
</model>
</elementSpec>
<elementSpec ident="cb" mode="change">
Expand Down
5 changes: 3 additions & 2 deletions src/teipb/transform/parzival-verse-epub.xql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import module namespace global="http://www.tei-c.org/tei-simple/config" at "../m

(: generated template function for element spec: l :)
declare %private function model:template-l($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><span class="verse" data-verse="{$config?apply-children($config, $node, $params?id)}">{$config?apply-children($config, $node, $params?verse)}</span><span class="content">{$config?apply-children($config, $node, $params?content)}</span></t>/*
<t xmlns=""><span class="verse" data-verse="{$config?apply-children($config, $node, $params?id)}">{$config?apply-children($config, $node, $params?verse)}<sup>{$config?apply-children($config, $node, $params?afterDash)}</sup></span><span class="content">{$config?apply-children($config, $node, $params?content)}</span></t>/*
};
(: generated template function for element spec: ptr :)
declare %private function model:template-ptr($config as map(*), $node as node()*, $params as map(*)) {
Expand Down Expand Up @@ -162,7 +162,8 @@ declare function model:apply($config as map(*), $input as node()*) {
map {
"id": substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),
"content": .,
"verse": concat(substring-before(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),'.'),'.',number(substring-after(if (@xml:id) then @xml:id else @n, '.')))
"verse": let $verse := substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' ') let $afterDot := substring-after($verse, '.') let $beforeDash := if (contains($afterDot, '-')) then substring-before($afterDot, '-') else $afterDot return concat( substring-before($verse, '.'), '.', number($beforeDash) ),
"afterDash": let $afterDot := substring-after(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '), '.') return if (contains($afterDot, '-')) then substring-after($afterDot, '-') else ''
}

let $content :=
Expand Down
5 changes: 3 additions & 2 deletions src/teipb/transform/parzival-verse-fo.xql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import module namespace global="http://www.tei-c.org/tei-simple/config" at "../m

(: generated template function for element spec: l :)
declare %private function model:template-l($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><span class="verse" data-verse="{$config?apply-children($config, $node, $params?id)}">{$config?apply-children($config, $node, $params?verse)}</span><span class="content">{$config?apply-children($config, $node, $params?content)}</span></t>/*
<t xmlns=""><span class="verse" data-verse="{$config?apply-children($config, $node, $params?id)}">{$config?apply-children($config, $node, $params?verse)}<sup>{$config?apply-children($config, $node, $params?afterDash)}</sup></span><span class="content">{$config?apply-children($config, $node, $params?content)}</span></t>/*
};
(: generated template function for element spec: ptr :)
declare %private function model:template-ptr($config as map(*), $node as node()*, $params as map(*)) {
Expand Down Expand Up @@ -154,7 +154,8 @@ declare function model:apply($config as map(*), $input as node()*) {
map {
"id": substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),
"content": .,
"verse": concat(substring-before(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),'.'),'.',number(substring-after(if (@xml:id) then @xml:id else @n, '.')))
"verse": let $verse := substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' ') let $afterDot := substring-after($verse, '.') let $beforeDash := if (contains($afterDot, '-')) then substring-before($afterDot, '-') else $afterDot return concat( substring-before($verse, '.'), '.', number($beforeDash) ),
"afterDash": let $afterDot := substring-after(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '), '.') return if (contains($afterDot, '-')) then substring-after($afterDot, '-') else ''
}

let $content :=
Expand Down
5 changes: 3 additions & 2 deletions src/teipb/transform/parzival-verse-latex.xql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import module namespace global="http://www.tei-c.org/tei-simple/config" at "../m

(: generated template function for element spec: l :)
declare %private function model:template-l($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><span class="verse" data-verse="{$config?apply-children($config, $node, $params?id)}">{$config?apply-children($config, $node, $params?verse)}</span><span class="content">{$config?apply-children($config, $node, $params?content)}</span></t>/*
<t xmlns=""><span class="verse" data-verse="{$config?apply-children($config, $node, $params?id)}">{$config?apply-children($config, $node, $params?verse)}<sup>{$config?apply-children($config, $node, $params?afterDash)}</sup></span><span class="content">{$config?apply-children($config, $node, $params?content)}</span></t>/*
};
(: generated template function for element spec: ptr :)
declare %private function model:template-ptr($config as map(*), $node as node()*, $params as map(*)) {
Expand Down Expand Up @@ -162,7 +162,8 @@ declare function model:apply($config as map(*), $input as node()*) {
map {
"id": substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),
"content": .,
"verse": concat(substring-before(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),'.'),'.',number(substring-after(if (@xml:id) then @xml:id else @n, '.')))
"verse": let $verse := substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' ') let $afterDot := substring-after($verse, '.') let $beforeDash := if (contains($afterDot, '-')) then substring-before($afterDot, '-') else $afterDot return concat( substring-before($verse, '.'), '.', number($beforeDash) ),
"afterDash": let $afterDot := substring-after(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '), '.') return if (contains($afterDot, '-')) then substring-after($afterDot, '-') else ''
}

let $content :=
Expand Down
5 changes: 3 additions & 2 deletions src/teipb/transform/parzival-verse-print.xql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import module namespace global="http://www.tei-c.org/tei-simple/config" at "../m

(: generated template function for element spec: l :)
declare %private function model:template-l($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><span class="verse" data-verse="{$config?apply-children($config, $node, $params?id)}">{$config?apply-children($config, $node, $params?verse)}</span><span class="content">{$config?apply-children($config, $node, $params?content)}</span></t>/*
<t xmlns=""><span class="verse" data-verse="{$config?apply-children($config, $node, $params?id)}">{$config?apply-children($config, $node, $params?verse)}<sup>{$config?apply-children($config, $node, $params?afterDash)}</sup></span><span class="content">{$config?apply-children($config, $node, $params?content)}</span></t>/*
};
(: generated template function for element spec: ptr :)
declare %private function model:template-ptr($config as map(*), $node as node()*, $params as map(*)) {
Expand Down Expand Up @@ -162,7 +162,8 @@ declare function model:apply($config as map(*), $input as node()*) {
map {
"id": substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),
"content": .,
"verse": concat(substring-before(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),'.'),'.',number(substring-after(if (@xml:id) then @xml:id else @n, '.')))
"verse": let $verse := substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' ') let $afterDot := substring-after($verse, '.') let $beforeDash := if (contains($afterDot, '-')) then substring-before($afterDot, '-') else $afterDot return concat( substring-before($verse, '.'), '.', number($beforeDash) ),
"afterDash": let $afterDot := substring-after(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '), '.') return if (contains($afterDot, '-')) then substring-after($afterDot, '-') else ''
}

let $content :=
Expand Down
5 changes: 3 additions & 2 deletions src/teipb/transform/parzival-verse-web.xql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import module namespace global="http://www.tei-c.org/tei-simple/config" at "../m

(: generated template function for element spec: l :)
declare %private function model:template-l($config as map(*), $node as node()*, $params as map(*)) {
<t xmlns=""><span class="verse" data-verse="{$config?apply-children($config, $node, $params?id)}">{$config?apply-children($config, $node, $params?verse)}</span><span class="content">{$config?apply-children($config, $node, $params?content)}</span></t>/*
<t xmlns=""><span class="verse" data-verse="{$config?apply-children($config, $node, $params?id)}">{$config?apply-children($config, $node, $params?verse)}<sup>{$config?apply-children($config, $node, $params?afterDash)}</sup></span><span class="content">{$config?apply-children($config, $node, $params?content)}</span></t>/*
};
(: generated template function for element spec: ptr :)
declare %private function model:template-ptr($config as map(*), $node as node()*, $params as map(*)) {
Expand Down Expand Up @@ -160,7 +160,8 @@ declare function model:apply($config as map(*), $input as node()*) {
map {
"id": substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),
"content": .,
"verse": concat(substring-before(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '),'.'),'.',number(substring-after(if (@xml:id) then @xml:id else @n, '.')))
"verse": let $verse := substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' ') let $afterDot := substring-after($verse, '.') let $beforeDash := if (contains($afterDot, '-')) then substring-before($afterDot, '-') else $afterDot return concat( substring-before($verse, '.'), '.', number($beforeDash) ),
"afterDash": let $afterDot := substring-after(substring-after(if (@xml:id) then @xml:id else @n, if (@xml:id) then '_' else ' '), '.') return if (contains($afterDot, '-')) then substring-after($afterDot, '-') else ''
}

let $content :=
Expand Down

0 comments on commit 6f864c2

Please sign in to comment.