def multisplit(container, name, xpath, before=True):
 root = container.parsed(name)
 nodes = root.xpath(xpath, namespaces=XPNSMAP)
 if (not nodes):
  raise AbortError((_(u'The expression %s did not match any nodes') % xpath))
 for split_point in nodes:
  if in_table(split_point):
   raise AbortError(u'Cannot split inside tables')
  if split_point.tag.endswith(u'}body'):
   raise AbortError(u'Cannot split on the <body> tag')
 for (i, tag) in enumerate(nodes):
  tag.set(u'calibre-split-point', str(i))
 current = name
 all_names = [name]
 for i in xrange(len(nodes)):
  current = split(container, current, (u'//*[@calibre-split-point="%d"]' % i), before=before)
  all_names.append(current)
 for x in all_names:
  for tag in container.parsed(x).xpath(u'//*[@calibre-split-point]'):
   tag.attrib.pop(u'calibre-split-point')
  container.dirty(x)
 return all_names[1:]

def multisplit ( container , name , xpath , before = True ) : root = container . parsed ( name ) nodes = root . xpath ( xpath , namespaces = XPNSMAP ) if ( not nodes ) : raise AbortError ( ( _ ( u'The expression %s did not match any nodes' ) % xpath ) ) for split_point in nodes : if in_table ( split_point ) : raise AbortError ( u'Cannot split inside tables' ) if split_point . tag . endswith ( u'}body' ) : raise AbortError ( u'Cannot split on the <body> tag' ) for ( i , tag ) in enumerate ( nodes ) : tag . set ( u'calibre-split-point' , str ( i ) ) current = name all_names = [ name ] for i in xrange ( len ( nodes ) ) : current = split ( container , current , ( u'//*[@calibre-split-point="%d"]' % i ) , before = before ) all_names . append ( current ) for x in all_names : for tag in container . parsed ( x ) . xpath ( u'//*[@calibre-split-point]' ) : tag . attrib . pop ( u'calibre-split-point' ) container . dirty ( x ) return all_names [ 1 : ]
split the specified file at multiple locations (all tags that match the specified xpath expression .