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

View File

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