def sax_excludes(self):
     self.startElementNS(NS_NEWS_URI, "excludes")
     exported = self.getExported()
     for item in self.context.get_excluded_items():
         if is_inside_container(exported.root, item):
             path = [exported.root.getId()] + relative_path(
                 exported.rootPath, item.getPhysicalPath())
             path = canonical_path('/'.join(path))
             self.startElementNS(
                 NS_NEWS_URI, 'exclude', {'target': path})
             self.endElementNS(NS_NEWS_URI, 'exclude')
         else:
             exported.reportProblem(
                 'Content excluded from the filter was not exported',
                 content=self.context)
     self.endElementNS(NS_NEWS_URI, "excludes")
 def serializeValue(self, field, value, producer):
     if not value:
         return
     handler = producer.getHandler()
     options = handler.getOptions()
     if options.external_rendering:
         return
     if not bool(field.get_value('multiple')):
         value = [value]
     exported = handler.getExported()
     producer.startPrefixMapping(None, NS_REFERENCES)
     for target in value:
         if value is not None:
             if is_inside_container(exported.root, target):
                 target_path = [exported.root.getId()] + relative_path(
                     exported.rootPath, target.getPhysicalPath())
                 producer.startElement('path')
                 producer.characters(canonical_path('/'.join(target_path)))
                 producer.endElement('path')
             else:
                 if options.external_references:
                     exported.reportProblem(
                         (u"A reference field '{0}' refers to an " +
                          u'content outside of the export ({1}).').format(
                             field.getId(),
                             '/'.join(relative_path(
                                     exported.rootPath,
                                     target.getPhysicalPath()))),
                         producer.context)
                     producer.startElement('path')
                     producer.endElement('path')
                 else:
                     raise ExternalReferenceError(
                         _(u"External reference"),
                         producer.context, target, exported.root)
     producer.endPrefixMapping(None)