MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Sigil (https://www.mobileread.com/forums/forumdisplay.php?f=203)
-   -   @DiapDealer ISBN vs UUID (https://www.mobileread.com/forums/showthread.php?t=314516)

Trane 01-19-2019 06:03 PM

@DiapDealer ISBN vs UUID
 
Hello DiapDealer...

Found an old thread where you answered the question I have, which is how to use the ISBN in the metadata, vs the UUID... but I am new to opf and metadata code and am too dense ... I kindly need an example of what you mean. You said in this previous post in 2013):

"It's quite trivial to change your ePub to use the ISBN identifier as the unique identifier (in Sigil) and get rid of the autogenerated UUID at any time, however:

"Add the ISBN metadata (either through the metadata editor or add it manually in the OPF). Open the OPF file and add an id attribute to the isbn dc:indentifier entry you just created (I often use "isbn" but just so long as it's not the same as the "unique-identifier" attribute of the "package" element). Then change the "unique-identifier" attribute of the "package" element to match the id you just created for your ISBN entry. Save the epub and delete the entire <dc:identifier></dc:identifier> entry for the old UUID from the OPF."

You lost me at "add an id attribute to the isbn identifier..."

This is the relevant code (I think):

<package version="2.0" unique-identifier="BookId" xmlns="http://www.idpf.org/2007/opf">

<metadata xmlns:opf="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/">

<dc:identifier opf:scheme="ISBN">ISBN [isbn # here]</dc:identifier>


I don't know the protocol for adding an attribute to a dc element.. ? If it needs dashes or underscores or colons or a single space or what? Sorry! Could you give an example...? I'd really appreciate it.

Turtle91 01-19-2019 06:32 PM

On the first line you are simply telling what the name of the variable is that you are using for the unique-identifier. In this example it is "uid".

<package version="2.0" unique-identifier="uid" xmlns="http://www.idpf.org/2007/opf">

Then you are defining what that variable is:

<dc:identifier id="uid">4183454533</dc:identifier>

You can easily use the ISBN like this:
<package version="2.0" unique-identifier="BookID" xmlns="http://www.idpf.org/2007/opf">
<dc:identifier id="BookID">ISBN [isbn # here]</dc:identifier>

Trane 01-19-2019 07:07 PM

Quote:

Originally Posted by Turtle91 (Post 3800843)
On the first line you are simply telling what the name of the variable is that you are using for the unique-identifier. In this example it is "uid".

<package version="2.0" unique-identifier="uid" xmlns="http://www.idpf.org/2007/opf">

Then you are defining what that variable is:

<dc:identifier id="uid">4183454533</dc:identifier>

You can easily use the ISBN like this:
<package version="2.0" unique-identifier="BookID" xmlns="http://www.idpf.org/2007/opf">
<dc:identifier id="BookID">ISBN [isbn # here]</dc:identifier>

Thanks so much Turtle91. I will try this tomorrow... I have read myself into a muddy brain.. I just found inadvertently that I should have the entry for dc:publisher to be the top level publishing company, but this book is published by an imprint of mine under that, so I am supposed to add <imprint> in the metadata somehow. I tried 10x to do this, expecting it to look like this:

dc:publisher Top Level Pub Co. Here
dc:imprint Imprint Publisher Here

... which it does look like that in the metadata window... but when I switch to opf file, I see it inserts it with a name tag and encloses it in meta brackets... instead of just listing dc:imprint under all the other dc:xxxx elements. So not sure I am getting that right either.

I know this is no-brainer stuff that takes one second to those familiar!

EDIT: Argh, even my posts are making fun of me, inserting smileys!

Tex2002ans 01-19-2019 07:49 PM

I'll try to color-code my stuff, maybe that'll make it easier to understand too!

Let's say you rip open a book created in Sigil.

In your content.opf, you'll see something like this:

Spoiler:
Quote:

<?xml version="1.0" encoding="utf-8"?>
<package version="2.0" unique-identifier="BookId" xmlns="http://www.idpf.org/2007/opf">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">

<dc:language>en</dc:language>
<dc:title>[Title here]</dc:title>
<dc:identifier opf:scheme="ISBN">1-23456-789-0</dc:identifier>
<dc:identifier opf:scheme="UUID" id="BookId">urn:uuid:73be470e-4da2-4f78-83bf-7ac69507aa66</dc:identifier>

</metadata>
[...]


These two always have to match:

- unique-identifier (up top)
- id (down below)

You can see they both say BookId.

Note: Sigil uses "BookId", but you could call this anything.

Note #2: The blue part is just a randomly generated UUID. All books are probably going to have different gibberish here depending on which program built it.

Method 1

As Diap initially explained, you can change "BookId" to whatever name you name want. He mentioned he likes to use "isbn".

So change both red parts, and move the id to where it's needed:

Spoiler:
Quote:

<?xml version="1.0" encoding="utf-8"?>
<package version="2.0" unique-identifier="isbn" xmlns="http://www.idpf.org/2007/opf">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">

<dc:language>en</dc:language>
<dc:title>[Title here]</dc:title>
<dc:identifier opf:scheme="ISBN" id="isbn">1-23456-789-0</dc:identifier>
<dc:identifier opf:scheme="UUID" id="BookId">urn:uuid:73be470e-4da2-4f78-83bf-7ac69507aa66</dc:identifier>

</metadata>
[...]


Remove the entire Blue line because it's not needed any more:

Spoiler:
Quote:

<?xml version="1.0" encoding="utf-8"?>
<package version="2.0" unique-identifier="isbn" xmlns="http://www.idpf.org/2007/opf">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">

<dc:language>en</dc:language>
<dc:title>[Title here]</dc:title>
<dc:identifier opf:scheme="ISBN" id="isbn">1-23456-789-0</dc:identifier>

</metadata>
[...]


Method 2

Or as Turtle91 said:

Just move the id="BookId":

Spoiler:
Quote:

<?xml version="1.0" encoding="utf-8"?>
<package version="2.0" unique-identifier="BookId" xmlns="http://www.idpf.org/2007/opf">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">

<dc:language>en</dc:language>
<dc:title>[Title here]</dc:title>
<dc:identifier opf:scheme="ISBN" id="BookId">1-23456-789-0</dc:identifier>
<dc:identifier opf:scheme="UUID">urn:uuid:73be470e-4da2-4f78-83bf-7ac69507aa66</dc:identifier>

</metadata>
[...]


And you can delete the entire blue line:

Spoiler:
Quote:

<?xml version="1.0" encoding="utf-8"?>
<package version="2.0" unique-identifier="BookId" xmlns="http://www.idpf.org/2007/opf">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">

<dc:language>en</dc:language>
<dc:title>[Title here]</dc:title>
<dc:identifier opf:scheme="ISBN" id="BookId">1-23456-789-0</dc:identifier>

</metadata>
[...]


Quote:

Originally Posted by Trane (Post 3800857)
EDIT: Argh, even my posts are making fun of me, inserting smileys!

Use [noparse][/noparse] tags around those stupid smilies. :P

Or when you're in the Advanced Editor, right below "Submit Reply" button, you can see a little checkbox for Disable smilies in text.

DiapDealer 01-19-2019 08:16 PM

I have nothing to add. :D

Tex2002ans 01-20-2019 08:40 AM

Quote:

Originally Posted by DiapDealer (Post 3800877)
I have nothing to add. :D

First time I've seen a user called out in the title of a post. :rofl:

And on a post from 2013 too! Must be a record. :D

DiapDealer 01-20-2019 11:34 AM

I was just happy you guys saved me the trouble of having to go back and do my homework. :o

Tex2002ans 01-20-2019 02:28 PM

Quote:

Originally Posted by DiapDealer (Post 3801019)
I was just happy you guys saved me the trouble of having to go back and do my homework. :o

I almost never manually edit the OPF. I just let Sigil/Calibre take care of that for me.

But I'm not sure about the toc.ncx, does this line have to be updated as well?

toc.ncx:

Code:

<meta name="dtb:uid" content="urn:uuid:acfa4835-af6c-4301-87f9-8c3ce0b9df94" />
When Sigil generates a new file, it matches the UUID in the toc.ncx + the UUID in the content.opf.

Not too sure what you should update if you manually remove the UUID.

Trane 01-20-2019 02:59 PM

@Tex2002ans Thanks SO MUCH for that super clear tutorial. Always appreciate the help I get here.... you guys are invaluable.

I will check back to see if I should edit the tox as well. Again, can't thank you enough.

BeckyEbook 01-20-2019 02:59 PM

Quote:

Originally Posted by Tex2002ans (Post 3801063)
Not too sure what you should update if you manually remove the UUID.

Sure.
Without an update you will get an error (EpubCheck):
Code:

ERROR(NCX-001):  NCX identifier ('urn:uuid:acfa4835-af6c-4301-87f9-8c3ce0b9df9') does not match OPF identifier ('1-23456-789-0').

Trane 01-20-2019 03:41 PM

Quote:

Originally Posted by BeckyEbook (Post 3801073)
Sure.
Without an update you will get an error (EpubCheck):
Code:

ERROR(NCX-001):  NCX identifier ('urn:uuid:acfa4835-af6c-4301-87f9-8c3ce0b9df9') does not match OPF identifier ('1-23456-789-0').

Thanks Becky.... I did manually update the tox (and opf) and ran through EpubCheck ... no issues, thanks ONLY to the supportive, wonderful, guides here! :bow2:

Don't know where I would be without Sigil and this forum!!! MANY THANKS!

Trane 01-20-2019 05:13 PM

PS In this line:

<dc:identifier opf:scheme="UUID" id="ISBN">urn:uuid:[isbn # here]</dc:identifier>

... I changed the blue to "urn:isbn" ... As stated, no errors in EpubCheck, but Kindle Converter hangs for first time and won't convert. When I hit cancel it says "check file, it might be corrupted."

Should I leave it as "urn:uuid" ?

EDIT: Never mind, the answer was in Tex's post!

DiapDealer 01-20-2019 05:20 PM

The ncx dbt:uid entry being flagged if it doesn't match the opf unique-id is actually relatively new to Epubcheck. I'm almost certain it wasn't problem back in 2013. ;)

In all honesty, I wouldn't even bother removing the uuid, or changing the unique-id from the uuid to the new isbn entry. It's really not worth the trouble, and there's absolutely no advantage to be gained. Just leave the uuid, the unique-id, and the ncx dbt:uid alone; then add a new ISBN meta item and be done with it.

I can't remember the last commercial epub I looked at that used the isbn as the unique identifier. *shrug*

Trane 01-20-2019 05:54 PM

Quote:

Originally Posted by DiapDealer (Post 3801112)
The ncx dbt:uid entry being flagged if it doesn't match the opf unique-id is actually relatively new to Epubcheck. I'm almost certain it wasn't problem back in 2013. ;)

In all honesty, I wouldn't even bother removing the uuid, or changing the unique-id from the uuid to the new isbn entry It's really not worth the trouble, and there's absolutely no advantage to be gained. Just leave the uuid, the unique-id, and the ncx dbt:uid alone; then add a new ISBN meta item and be done with it.

I can't remember the last commercial epub I looked at that used the isbn as the unique identifier. *shrug*

Well it would seem you have a point (no surprise there!). :D Because I made a copy of the epub after I added the ISBN, but before making any code changes. And that copy converts in Kindle Converter, no problem.

But regardless of what I do, the one whose code I changed (and re-checked many times now) will not convert, even though it gets zero errors in EpubCheck.

I feel bad I made Tex take all that time to explain how to do all that to me, but FWIW (Tex), I did learn in the process... about code too, which I appreciate!

But it looks like I will do as you suggest, as that seems to be the only way the Kindle Converter program is happy with it. So I'll leave well enough alone.

BTW, I read the ISBN should be entered in the metadata field without hyphens. Is that the consensus?

Again, a million thanks!

Tex2002ans 01-21-2019 12:30 AM

Quote:

Originally Posted by DiapDealer (Post 3801112)
I can't remember the last commercial epub I looked at that used the isbn as the unique identifier. *shrug*

I just looked through a few of my purchased books.

I recently purchased Wheel of Time Books #1-#6. #1 had an ISBN as the ID. The others used UUIDs.

And The Expanse Book #5 had mismatching:

content.opf:

Quote:

<package version="3.0" unique-identifier="pub-id" xml:lang="en" xmlns="http://www.idpf.org/2007/opf">

[...]

<dc:identifier id="pub-id">urn:uuid:0b1a10e6-1feb-4d17-8695-8bbe5c18dacf</dc:identifier>
toc.ncx:

Quote:

<meta content="9780316217590" name="dtb:uid"/>
... tisk tisk!

And another Tor book had:

content.opf:

Quote:

<package version="3.0" unique-identifier="pub-identifier" xmlns="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/" prefix="ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/" xml:lang="en" xmlns:dcterms="http://purl.org/dc/terms/">
<metadata>
<dc:identifier id="pub-identifier">randomid-d13</dc:identifier>
lol. Good ID, good ID.

Quote:

Originally Posted by DiapDealer (Post 3801112)
In all honesty, I wouldn't even bother removing the uuid, or changing the unique-id from the uuid to the new isbn entry. It's really not worth the trouble, and there's absolutely no advantage to be gained. Just leave the uuid, the unique-id, and the ncx dbt:uid alone; then add a new ISBN meta item and be done with it.

I think it may be used by some reading systems for highlights.

(Because I've had books where I've cleaned up/converted, forgot to change UUID, and the highlights carry over in all the wrong locations. After copying/pasting in new info, the old highlights disappeared.)

Quote:

Originally Posted by Trane (Post 3801125)
BTW, I read the ISBN should be entered in the metadata field without hyphens. Is that the consensus?

Where did you read this?

I just insert it exactly as it looks as ISBN-10 or ISBN-13.


All times are GMT -4. The time now is 09:17 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.