From 96e9786f5aba1078251f36e58feefc8d953cdea0 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 8 Aug 2017 16:54:24 +0200 Subject: [PATCH 1/3] EPUBGenerator: fix validation error with empty dc:identifier element "3.4.3.2.1 The identifier Element" says that the character content is not optional, so write it. --- configure.ac | 3 +++ src/lib/EPUBGenerator.cpp | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp index 0d0f866..507eb14 100644 --- a/src/lib/EPUBGenerator.cpp +++ b/src/lib/EPUBGenerator.cpp @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include +#include +#include + #include "EPUBCSSSink.h" #include "EPUBHTMLGenerator.h" #include "EPUBGenerator.h" @@ -193,7 +197,15 @@ void EPUBGenerator::writeRoot() RVNGPropertyList identifierAttrs; identifierAttrs.insert("id", uniqueId); - sink.insertEmptyElement("dc:identifier", identifierAttrs); + identifierAttrs.insert("opf:scheme", "UUID"); + sink.openElement("dc:identifier", identifierAttrs); + // The identifier element is required to have a unique character content. + std::stringstream identifierStream("urn:uuid:"); + boost::uuids::uuid uuid = boost::uuids::random_generator()(); + identifierStream << uuid; + std::string identifierCharactrs = identifierStream.str(); + sink.insertCharacters(identifierCharactrs.c_str()); + sink.closeElement("dc:identifier"); sink.openElement("dc:title"); sink.closeElement("dc:title"); -- 2.12.3