-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added option to choose navigation root #107
base: master
Are you sure you want to change the base?
Conversation
modules/lib/api.json
Outdated
"in": "query", | ||
"schema": { | ||
"type": "string", | ||
"example": "/1/4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test below uses a value of 1/4
, but this example has a leading slash - /1/4
. Is the leading slash optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, it should be /1/4
won't work, I will update it
@ccheraa By "navigation pane", do you mean the TEI Publisher app's own table of contents pane, or are you referring to an ebook reader/client app's table of contents? |
modules/lib/api/document.xql
Outdated
@@ -326,7 +326,8 @@ declare function dapi:epub($request as map(*)) { | |||
}; | |||
|
|||
declare %private function dapi:work2epub($request as map(*), $id as xs:string, $work as document-node(), $lang as xs:string?) { | |||
let $config := $config:epub-config($work, $lang) | |||
let $navRoot := fn:fold-left(tokenize($request?parameters?nav-root, '/'), (), function($a, $b) { (if (not(empty($a))) then $a else $work)/node()[position()=xs:integer($b)] }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TEI Publisher application makes extensive use of the functions util:node-id()
and util:node-by-id()
. I suspect they may exhibit better performance. Were you aware of these functions? If so, did you have a reason for opting not to use them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to use the position of the node instead because the node to be the root for navigation will most likely be text
or body
, which don't always have an ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The util:node-id()
and util:node-by-id()
functions do use the node's numeric position in the node hierarchy. For their function documentation, see https://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/util#node-by-id.2.
For example, given the sample TEI file from your test saved to /db/test/test.xml
, the query util:node-id(doc("/db/test/test.xml")/tei:TEI/tei:text)
returns 1.4
, and correspondingly, the query util:node-by-id(doc("/db/test/test.xml"), "1.4")
returns the <text>
element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't thought of using that, I will test it and let you know.
I mean the navigation pane of the ebook reader |
currently, the navigation root is determined as the parent of the first document found, this may omit some documents from the navigation pane if their first common ancestor is not their parent
so by providing a path to the correct navigation root, we can make sure that all documents appear in the navigation pane, and that's by using the
nav-root
query parameter, for example, as follows:1/1/3
means that the navigation root node should be$doc/node()[1]/node()[1]/node()[3]
This open source contribution to the tei-publisher-app project was commissioned by the Office of the Historian, U.S. Department of State, https://history.state.gov.