View Single Post
Old 02-26-2018, 05:52 PM   #367
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 9,253
Karma: 6565382
Join Date: Nov 2009
Device: many
To make it a more official epubcfi, you would need to convert it to be:

epubcfi(/6/4!/4/4)

The first /6 tells it to find the 3rd tag child on the content.opf package tag, which is the spine, and then the /4 means to take the second tag child of the spine tag (the itemref for Section0001.xhtml). The ! means to follow the idref to access the correct file href in the manifest and redirect to it.

The remainder /4/4 from your cfi says to start with the html tag of the target file and take its 2nd tag child (body) and then the 2nd tag child of the body tag which is the line with the p tag with the epub:type="dedication" attribute.

If a node path ends with a n odd node number, it means it is a text node and a character offset into the text would be added after a : .

So for example, an epubcfi(/6/4/4/4/1:10) should point to the "d" in the word "dedication" in the text node with the string "This is a dedication."

Hope this helps.

KevinH


Quote:
Originally Posted by Doitsu View Post
I still don't fully understand the epubcfi format. For example, for a test epub3 book that I created ACE reported the following non-standard epubcfi:

Code:
Text/Section0001.xhtml#epubcfi(/4/4)
The actual Section0001.xhtml HTML code is:
Spoiler:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
  <title></title>
  <link href="../Styles/style.css" type="text/css" rel="stylesheet"/>
</head>

<body>
  <h1>Test 1</h1>

  <p epub:type="dedication">This is a dedication.</p>

  <p>This is a normal paragraph.</p>

  <p epub:type="notice">This is a notice.</p>
</body>
</html>


Assuming that Section0001.xhtml is the second spine entry, how would I need to reformat the above non-standard ACE epubcfi for use with your code?

The actual spine looks like this:
Spoiler:
Code:
  <spine toc="ncx">
    <itemref idref="nav.xhtml" linear="no"/>
    <itemref idref="Section0001.xhtml"/>
    <itemref idref="Section0002.xhtml"/>
  </spine>

Last edited by KevinH; 02-26-2018 at 06:06 PM.
KevinH is offline   Reply With Quote