1

Chapter_1.xhtml:

<div id="ch1_sec1">
<h1 id="level1">Section 1</h1>
<p id="p1">paragraph1, see <a href="Chapter_1.xhtml#f1">fig 1</a></p>
<figure id="f1">
<caption>Fig. 1. Caption</caption>
</figure>
<p id="p2">paragraph2, see <a href="Chapter_1.xhtml#f1">fig 2</a></p>
<p id="p3">paragraph3</p>
</div>

Chapter_2.xhtml:

<div id="ch2_sec1">
<h1 id="level1">Section 1</h1>
<p id="p1">paragraph1</p>
<p id="p2">paragraph2, see <a href="Chapter_1.xhtml#f1">fig 2</a></p>
<figure id="f1">
<caption>Fig. 2. Caption</caption>
</figure>
<p id="p3">paragraph3</p>
</div>

Chapter_3.xhtml:

<div id="ch3_sec1">
<h1 id="level1">Section 1</h1>
<p id="p1">paragraph1</p>
<p id="p2">paragraph2</p>
<p id="p3">paragraph3</p>
</div>

In above mentioned source file, All the IDs are same except <div> ID. In this case, how can i find the duplicates with different filenames (using perl, javascript or anything else).

If you have solution for this, please help.

  • 1
    Could you explain why this is a problem exactly? You can have Chapter_2.xhtml#p1 and Chapter_3.xhtml#p1 without there being an ambiguous reference. Do you need this to specify a css class? – idiotprogrammer Sep 17 '15 at 17:44
  • Hi @idiotprogrammer, For example: Figure 1 has placed in Chapter_1.xhtml with id="f1" and Figure 2 has placed in Chapter_2.xhtml with the same id="f1". But the fig 2 cited in the Chapter_1.xhtml, when i run the script for href links, it will be linked like <a href="Chapter_1.xhtml#f1">Fig. 1.</a> and <a href="Chapter_1.xhtml#f1">Fig. 2.</a>. because the script is finding and linking with first id with different content. – mr.apandu Sep 18 '15 at 4:23
  • What do you mean by "when I run the script for href links." What script? Why are you running it? I am assuming that the code you list is your SOURCE code and not OUTPUT code from a script. Is that right? For the record, I use Docbook XSLT, and the output looks similar to what you have here. If it is your source, then you can change it yourself. If not, then your problem is your script/toolchain. – idiotprogrammer Sep 18 '15 at 19:05
  • 1
    Perhaps I am not reading your comments correctly, but in the example you gave with your figures, there is nothing wrong with the example; you just aren't providing enough information to understand your problem. That is the challenge of trying to ask a technical question :) – idiotprogrammer Sep 18 '15 at 19:09
1

Your best bet is to validate with EPUBCheck. That will catch dupe @ids and other errors. I use a command in Linux similar to:

java -jar /home/epubcheck.jar book.epub -out errors.xml

The errors.xml file will give you filename, line numbers, and error descriptions.

Or you can use an online validator at IDPF if you don't mind uploading your work.

0

download link validator http://lithopssoft.com/hlv/

drag and drop the file into the validator and click validate button. error will show on screen.

0

Validate the ePUB using EPUB check 3.0.1 or if the file is less than 10 MB then you can validate the file using online ePUB validator (http://validator.idpf.org/). This will definitely help in identifying the duplicate ID’s.

  • When I validated my home made EPUB, I believe this validator did not like the same IDs in different XHTML files, hence the user's question. Apparently EPUB does not allow the same ID in different XHTML files. This is why I include the XHTML filename in all my IDs now. So my id would be: id="ch1.xhtml_p1" – Bulrush Apr 18 '16 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.