EBook-Tools

 view release on metacpan or  search on metacpan

lib/EBook/Tools.pm  view on Meta::CPAN

        }

        foreach my $el (@elements) {
            $el->move('last_child',$xmeta);
        }
    }

    $output = $xmeta->first_child('output');
    if($output) {
	my $encoding = $mobiencodings{$output->att('encoding')};
	my $contenttype = $mobicontenttypes{$output->att('content-type')};

	if($contenttype) {
	    $output->set_att('encoding','utf-8') if(!$encoding);
	    debug(2,"DEBUG: setting encoding only and returning");
	    return 1;
	}
    }
    else {
        debug(1,"DEBUG: creating <output> under <x-metadata>");
        $output = $xmeta->insert_new_elt('last_child','output');
    }


    # At this stage, we definitely have <output> in the right place.
    # Set the attributes and return.
    $output->set_att('encoding' => 'utf-8',
		     'content-type' => 'text/x-oeb1-document');
    debug(2,"DEBUG[/",$subname,"]");
    return 1;
}


=head2 C<fix_oeb12()>

Modifies the OPF data to conform to the OEB 1.2 standard

Specifically, this involves:

t/mobi/langtest.opf  view on Meta::CPAN


<package xmlns="http://openebook.org/namespaces/oeb-package/1.0/" unique-identifier="UID">
  <metadata>
    <dc-metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
      <dc:Identifier id="UID" scheme="GUID">{28D17050-173C-11D5-9303-0010DA63A409}</dc:Identifier>
      <dc:Title>A Noncompliant OPF Test Sample</dc:Title>
      <dc:Creator file-as="Pobre, Zed 1" role="author">Zed 1 Pobre</dc:Creator>
      <dc:Language>zu</dc:Language>
    </dc-metadata>
    <x-metadata>
      <output encoding="utf-8" content-type="text/x-oeb1-document">
      </output>
    </x-metadata>
  </metadata>
  <manifest>
    <item media-type="application/xhtml+xml" href="test.html" id="item-text"/>
  </manifest>
  <spine>
    <itemref idref="item-text"/>
  </spine>
</package>

t/mobi/mobitest.opf  view on Meta::CPAN

      <dc:Contributor file-as="Myself, Me" role="ann">Me Myself</dc:Contributor>
      <dc:Contributor file-as="Himself, Him" role="ill">Him Himself</dc:Contributor>
      <dc:Date>10/01/2008</dc:Date>
      <dc:Date>11/1/2008</dc:Date>
      <dc:Type>Testing Type</dc:Type>
      <dc:Format>text/xml</dc:Format>
      <dc:Language>en</dc:Language>
    </dc-metadata>
    <x-metadata>
      <DefaultLookupKey>DLK</DefaultLookupKey>
      <output encoding="utf-8" content-type="text/x-oeb1-document" flatten-dynamic-dir="yes">
      </output>
      <Adult>yes</Adult>
      <DefaultLookupIndex>DLI</DefaultLookupIndex>
      <DictionaryInLanguage>de-at</DictionaryInLanguage>
      <DictionaryOutLanguage>es-ar</DictionaryOutLanguage>
      <Review>&lt;P&gt;Review line 1 — &lt;EM&gt;emphasized&lt;/EM&gt;&lt;/P&gt; &lt;P&gt;Review line 2 — &lt;STRONG&gt;a bold move&lt;/STRONG&gt;&lt;/P&gt;</Review>
      <SRP Currency="USD">1.23</SRP>
      <Territory>Territory</Territory>
    </x-metadata>
  </metadata>

t/testopf-missingfwid.xml  view on Meta::CPAN

  <dc:Date event="publication">03/01/2008</dc:Date>
  <dc:date opf:event="badfebday">2/31/2004</dc:date>
  <dc:Date opf:event="YYYY-xx-DD">2009-xx-01</dc:Date>
  <dc:Type>Text</dc:Type>
  <dc:format>text/html</dc:format>
  <dc:identifier scheme="ISBN">X-0000-9999-1</dc:identifier>
  <dc:identifier id="emptyUID"></dc:identifier>
  <dc:language>en-us</dc:language>
  <dc:Language>en-us</dc:Language>
  <dc:rights>Copyright &copy; 1991 by Zed Pobre</dc:rights>
  <output encoding="utf-8" content-type="text/x-oeb1-document"/>
  <item href="part1.html" id="item-text" media-type="application/xhtml+xml" />
  <item href="missingfile.html" id="file-missing" media-type="application/xhtml+xml" />
  <item href="cover.jpg"  id="coverimage" media-type="image/jpeg"/>
  <itemref idref="item-text"/>
  <itemref idref="file-missing" />
  <itemref idref="item-missing" />
</package>



( run in 2.419 seconds using v1.01-cache-2.11-cpan-524268b4103 )