docs: @SuppressWarnings("unchecked")
      protected void validateTopicLinks(final BuildData buildData, final Set<String> bookIdAttributes) throws BuildProcessingException {
          final List<SpecTopic> topics = buildData.getBuildDatabase().getAllSpecTopics();
          final Set<Integer> processedTopics = new HashSet<Integer>();
          for (final SpecTopic specTopic : topics) {
              final BaseTopicWrapper<?> topic = specTopic.getTopic();
              final Document doc = specTopic.getXMLDocument();
  
              /*
               * We only to to process topics at this point and not spec topics. So check to see if the topic has all ready been
               * processed.
               */
              if (!processedTopics.contains(topic.getId())) {
                  processedTopics.add(topic.getId());
  
                  // Get the XRef links in the topic document
                  final Set<String> linkIds = new HashSet<String>();
                  DocBookBuildUtilities.getTopicLinkIds(doc, linkIds);
  
                  final List<String> invalidLinks = new ArrayList<String>();
  
                  for (final String linkId : linkIds) {
                      /*
                       * Check if the xref linkend id exists in the book. If the Tag Starts with our error syntax then we can
                       * ignore it
                       */
                      if (!bookIdAttributes.contains(linkId) && !linkId.startsWith(CommonConstants.ERROR_XREF_ID_PREFIX)) {
                          invalidLinks.add("\"" + linkId + "\"");
                      }
                  }
  
                  // If there were any invalid links then replace the XML with an error template and add an error message.
                  if (!invalidLinks.isEmpty()) {
                      final String xmlStringInCDATA = DocBookBuildUtilities.convertDocumentToCDATAFormattedString(doc,
                              getXMLFormatProperties());
                      buildData.getErrorDatabase().addError(topic, ErrorType.INVALID_CONTENT,
                              "The following link(s) " + CollectionUtilities.toSeperatedString(invalidLinks, ", ") +
                                      " don't exist. The processed XML is <programlisting>" + xmlStringInCDATA + "</programlisting>");
  
                      // Find the Topic ID
                      final Integer topicId = topic.getTopicId();
  
                      final List<ITopicNode> buildTopics = buildData.getBuildDatabase().getTopicNodesForTopicID(topicId);
                      for (final ITopicNode topicNode : buildTopics) {
                          DocBookBuildUtilities.setTopicNodeXMLForError(buildData, topicNode,
                                  getErrorInvalidValidationTopicTemplate().getValue());
                      }
                  }
              }
          }
      }