- Handle empty XML files while manifest trimming
  - Ignore <img/>s with non OPS raster image @src
This commit is contained in:
Marshall T. Vandegrift 2009-01-19 15:03:50 -05:00
parent 1a98b0c266
commit 7e63bc95e2
2 changed files with 4 additions and 4 deletions

View File

@ -180,7 +180,6 @@ class Serializer(object):
if not isinstance(elem.tag, basestring) \
or namespace(elem.tag) not in nsrmap:
return
hrefs = self.oeb.manifest.hrefs
tag = prefixname(elem.tag, nsrmap)
for attr in ('name', 'id'):
if attr in elem.attrib:
@ -203,7 +202,7 @@ class Serializer(object):
continue
elif attr == 'src':
href = item.abshref(val)
if href in hrefs:
if href in self.images:
index = self.images[href]
buffer.write('recindex="%05d"' % index)
continue

View File

@ -41,8 +41,9 @@ class ManifestTrimmer(object):
while unchecked:
new = set()
for item in unchecked:
if item.media_type in OEB_DOCS or \
item.media_type[-4:] in ('/xml', '+xml'):
if (item.media_type in OEB_DOCS or
item.media_type[-4:] in ('/xml', '+xml')) and \
item.data is not None:
hrefs = [sel(item.data) for sel in LINK_SELECTORS]
for href in chain(*hrefs):
href = item.abshref(href)