void EPUB::generate_content(const string& output) { XML xml; xml.start_document("1.0", "UTF-8"); xml.start_tag("package"); xml.add_attribute("xmlns", "http://www.idpf.org/2007/opf"); xml.add_attribute("unique-identifier", "dcidid"); xml.add_attribute("version", "2.0"); xml.start_tag("metadata"); xml.add_attribute("xmlns:dc", "http://purl.org/dc/elements/1.1/"); xml.add_attribute("xmlns:dcterms", "http://purl.org/dc/terms/"); xml.add_attribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); xml.add_attribute("xmlns:opf", "http://www.idpf.org/2007/opf"); xml.start_tag("dc:title"); if (!m_document->title().empty()) { xml.add_element(m_document->title().c_str()); } else { xml.add_element("No title"); } xml.end_tag(); xml.start_tag("dc:language"); xml.add_attribute("xsi:type", "dcterms:RFC3066"); xml.add_element(m_document->lang().c_str()); xml.end_tag(); xml.start_tag("dc:identifier"); xml.add_attribute("id", "dcidid"); xml.add_attribute("opf:scheme", "URI"); xml.add_element(output); xml.end_tag(); xml.start_tag("dc:subject"); xml.add_element(m_document->subject().c_str()); xml.end_tag(); xml.start_tag("dc:relation"); xml.add_element(PACKAGE_URL); xml.end_tag(); xml.start_tag("dc:creator"); if (m_document->author().empty()) { xml.add_element(PACKAGE_STRING); } else { xml.add_element(m_document->author().c_str()); } xml.end_tag(); xml.start_tag("dc:publisher"); xml.add_element(PACKAGE_STRING); xml.end_tag(); xml.start_tag("dc:publisher"); xml.add_element(m_document->author().c_str()); xml.end_tag(); xml.end_tag(); xml.start_tag("manifest"); xml.start_tag("item"); xml.add_attribute("id", "ncx"); xml.add_attribute("href", "toc.ncx"); xml.add_attribute("media-type", "application/x-dtbncx+xml"); xml.end_tag(); xml.start_tag("item"); xml.add_attribute("id", "part1"); xml.add_attribute("href", "pages.html"); xml.add_attribute("media-type", "application/xhtml+xml"); xml.end_tag(); xml.start_tag("item"); xml.add_attribute("id", "css"); xml.add_attribute("href", "style.css"); xml.add_attribute("media-type", "text/css"); xml.end_tag(); xml.end_tag(); xml.start_tag("spine"); xml.add_attribute("toc", "ncx"); xml.start_tag("itemref"); xml.add_attribute("idref", "part1"); xml.end_tag(); xml.end_tag(); xml.end_tag(); xml.end_document(); string content = xml.content(); m_zipfile->add_source("content.opf", content.c_str()); }
void EPUB::generate_toc(const string& output) { Outline *outline = m_document->outline(); XML xml; xml.start_document("1.0", "UTF-8"); xml.start_tag("ncx"); xml.add_attribute("xmlns", "http://www.daisy.org/z3986/2005/ncx/"); xml.add_attribute("version", "2005-1"); xml.start_tag("head"); xml.start_tag("meta"); xml.add_attribute("name", "dtb:uid"); xml.add_attribute("content", output); xml.end_tag(); xml.start_tag("meta"); xml.add_attribute("name", "dtb:depth"); xml.add_attribute("content", "2"); xml.end_tag(); xml.start_tag("meta"); xml.add_attribute("name", "dtb:totalPageCount"); xml.add_attribute("content", "0"); xml.end_tag(); xml.start_tag("meta"); xml.add_attribute("name", "dtb:maxPageNumber"); xml.add_attribute("content", "0"); xml.end_tag(); xml.end_tag(); xml.start_tag("docTitle"); xml.start_tag("text"); xml.add_element(m_document->title().c_str()); xml.end_tag(); xml.end_tag(); xml.start_tag("navMap"); if (outline) { generate_outline(&xml, outline); } else { xml.start_tag("navPoint"); xml.add_attribute("id", "navPoint-1"); xml.add_attribute("playOrder", "1"); xml.start_tag("navLabel"); xml.start_tag("text"); xml.add_element("Main Title"); xml.end_tag(); xml.end_tag(); xml.start_tag("content"); xml.add_attribute("src", "pages.html"); xml.end_tag(); xml.end_tag(); } xml.end_tag(); xml.end_tag(); xml.end_document(); string content = xml.content(); m_zipfile->add_source("toc.ncx", content.c_str()); }