You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And now two CFIs. With the first CFI I can successfully reference theh2 tag in the document but with the second not the first whitespace before the first opening b tag. The corresponding XPath is inspected here
In XPATH only character data with at least one character is grouped into a text node.
Character data is grouped into text nodes. As much character data as possible is grouped into each text node: a text node never has an immediately following or preceding sibling that is a text node. The string-value of a text node is the character data. _A text node always has at least one character of data._
Sadly, this changes epub content itself, and can cause performance issue. However, If you more care about consistency between CFI and Xpath, you can try.
Hi,
I'm currently debugging a problem with a specific CFI generated by me.
First the relevant HTML section (not the complete HTML document!)
And now two CFIs. With the first CFI I can successfully reference the
h2
tag in the document but with the second not the first whitespace before the first openingb
tag. The corresponding XPath is inspected hereepub.js/src/epubcfi.js
Line 511 in d8ba903
"epubcfi(/6/18!/4/352[h2-5]"
"./*/*[2]/*[position()=176 and @id='h2-5']/*[1]
"epubcfi(/6/18!/4/352[h2-5]/5:0)"
"./*/*[2]/*[position()=176 and @id='h2-5']/text()[2]"
I narrowed down the problem to a mismatch in the CFI and XPath spec. In CFI empty character data chunks are still indexed:
http://www.idpf.org/epub/linking/cfi/epub-cfi.html#sec-path-child-ref
In XPATH only character data with at least one character is grouped into a text node.
https://www.w3.org/TR/xpath/#section-Text-Nodes
Now the generated XPath (
epub.js/src/epubcfi.js
Line 448 in d8ba903
Maybe a fallback to the parent node is a possible solution?
The text was updated successfully, but these errors were encountered: