code: @Override
      public XBELDocument convert(Document source) {
          if (source == null) return null;
  
          XBELDocument xd = new XBELDocument();
  
          List<StatementGroup> stmtGroups = source.getStatementGroups();
          List<XBELStatementGroup> xstmtGroups = xd.getStatementGroup();
          StatementGroupConverter sgConverter = new StatementGroupConverter();
          for (final StatementGroup sg : stmtGroups) {
              // Defer to StatementGroupConverter
              xstmtGroups.add(sgConverter.convert(sg));
          }
  
          List<AnnotationDefinition> definitions = source.getDefinitions();
          if (hasItems(definitions)) {
              XBELAnnotationDefinitionGroup xadGroup =
                      new XBELAnnotationDefinitionGroup();
              List<XBELInternalAnnotationDefinition> internals =
                      xadGroup.getInternalAnnotationDefinition();
              List<XBELExternalAnnotationDefinition> externals =
                      xadGroup.getExternalAnnotationDefinition();
  
              InternalAnnotationDefinitionConverter iConverter =
                      new InternalAnnotationDefinitionConverter();
              ExternalAnnotationDefinitionConverter eConverter =
                      new ExternalAnnotationDefinitionConverter();
  
              for (final AnnotationDefinition ad : definitions) {
  
                  XBELInternalAnnotationDefinition iad = iConverter.convert(ad);
                  if (iad != null) {
                      internals.add(iad);
                      continue;
                  }
  
                  XBELExternalAnnotationDefinition ead = eConverter.convert(ad);
                  if (ead != null) {
                      externals.add(ead);
                  }
              }
              xd.setAnnotationDefinitionGroup(xadGroup);
          }
  
          Header header = source.getHeader();
          HeaderConverter hConverter = new HeaderConverter();
          // Defer to HeaderConverter
          xd.setHeader(hConverter.convert(header));
  
          NamespaceGroup nsGroup = source.getNamespaceGroup();
          if (nsGroup != null) {
              NamespaceGroupConverter ngConverter = new NamespaceGroupConverter();
              // Defer to NamespaceGroupConverter
              xd.setNamespaceGroup(ngConverter.convert(nsGroup));
          }
  
          return xd;
      }
docs: {@inheritDoc}