From 4ff60dbd8ca203473337263313e830b25feee152 Mon Sep 17 00:00:00 2001 From: Keith Fahlgren Date: Fri, 27 Mar 2009 01:59:46 +0000 Subject: [PATCH] Cleaning and regularizing the generation of namespaced nodes for OPF, NCX, XHTML and other outputted filetypes (hat tip to bobstayton for pointing out the silly, incorrect code) --- xsl/epub/bin/spec/epub_spec.rb | 4 +- xsl/epub/docbook.xsl | 127 +++++++++++++++------------------ 2 files changed, 60 insertions(+), 71 deletions(-) diff --git a/xsl/epub/bin/spec/epub_spec.rb b/xsl/epub/bin/spec/epub_spec.rb index e4ea0f635..6ab69c952 100755 --- a/xsl/epub/bin/spec/epub_spec.rb +++ b/xsl/epub/bin/spec/epub_spec.rb @@ -217,7 +217,7 @@ describe DocBook::Epub do success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{@css_epubfile}") raise "Could not unzip #{@css_epubfile}" unless success opf_files = Dir.glob(File.join(tmpdir, "**", "*.opf")) - opf_links = opf_files.find_all {|opf_file| File.open(opf_file).readlines.to_s =~ /]*#{@css_file_base}/} + opf_links = opf_files.find_all {|opf_file| File.open(opf_file).readlines.to_s =~ /<(opf:item|item) [^>]*#{@css_file_base}/} opf_links.should_not be_empty rescue => e raise e @@ -233,7 +233,7 @@ describe DocBook::Epub do success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{@css_epubfile}") raise "Could not unzip #{@css_epubfile}" unless success opf_files = Dir.glob(File.join(tmpdir, "**", "*.opf")) - opf_links = opf_files.find_all {|opf_file| File.open(opf_file).readlines.to_s =~ /]*#{@embedded_font_file_base}/} + opf_links = opf_files.find_all {|opf_file| File.open(opf_file).readlines.to_s =~ /<(opf:item|item) [^>]*#{@embedded_font_file_base}/} opf_links.should_not be_empty rescue => e raise e diff --git a/xsl/epub/docbook.xsl b/xsl/epub/docbook.xsl index 0c1c20600..151478a38 100644 --- a/xsl/epub/docbook.xsl +++ b/xsl/epub/docbook.xsl @@ -1,14 +1,21 @@ - + exclude-result-prefixes="exsl db dc h ncx ng opf odfc stext xtext" + + version="1.0"> @@ -217,12 +224,11 @@ - - http://www.idpf.org/2007/opf + 2.0 - + @@ -322,7 +328,7 @@ - + cover @@ -354,13 +360,10 @@ - - urn:oasis:names:tc:opendocument:xmlns:container + 1.0 - - urn:oasis:names:tc:opendocument:xmlns:container - - urn:oasis:names:tc:opendocument:xmlns:container + + @@ -390,9 +393,8 @@ - + 2005-1 - http://www.daisy.org/z3986/2005/ncx/ - + - + cover @@ -413,7 +415,7 @@ - + dtb:uid isbn: @@ -424,15 +426,15 @@ - + dtb:depth -1 - + dtb:totalPageCount 0 - + dtb:maxPageNumber 0 @@ -455,10 +457,10 @@ - - + + - + @@ -479,12 +481,12 @@ - - + + - + @@ -570,8 +572,7 @@ preceding::index)"/> - - http://www.daisy.org/z3986/2005/ncx/ + @@ -592,10 +593,10 @@ - - + + - + @@ -657,10 +658,9 @@ - - http://www.idpf.org/2007/opf + - + @@ -671,7 +671,7 @@ - + @@ -688,14 +688,13 @@ - - http://www.idpf.org/2007/opf + - + @@ -712,7 +711,7 @@ - + yes @@ -739,8 +738,7 @@ - - http://www.idpf.org/2007/opf + @@ -750,17 +748,16 @@ - - http://www.idpf.org/2007/opf + - + application/x-dtbncx+xml - + application/xhtml+xml @@ -772,8 +769,7 @@ - - http://www.idpf.org/2007/opf + text/css css @@ -781,8 +777,7 @@ - - http://www.idpf.org/2007/opf + @@ -793,8 +788,7 @@ - - http://www.idpf.org/2007/opf + epub.embedded.font @@ -866,8 +860,7 @@ - - http://www.idpf.org/2007/opf + @@ -975,8 +968,7 @@ - - http://www.idpf.org/2007/opf + @@ -1024,8 +1016,7 @@ - - http://www.idpf.org/2007/opf + @@ -1092,8 +1083,7 @@ - - http://www.idpf.org/2007/opf + application/xhtml+xml @@ -1439,18 +1429,17 @@ - - http://www.w3.org/1999/xhtml - - Cover - + + + Cover + text/css img { max-width: 100%; } - - + + -- 2.40.0