- def build(self, builder, **kwargs):
- return builder().build(self, **kwargs)
+ def build(self, builder, base_url=None, **kwargs):
+ return builder(base_url=base_url).build(self, **kwargs)
+
+ def assign_ids(self, existing=None):
+ # Find all existing IDs.
+ existing = existing or set()
+ que = [self.tree.getroot()]
+ while que:
+ item = que.pop(0)
+ try:
+ item.normalize_insides()
+ except AttributeError:
+ pass
+ existing.add(item.attrib.get('id'))
+ que.extend(item)