/**
   * Parses the given author string and returns the result as DOM node. The returned XML has the
   * following structure: <authors> <author> <familyname>Buxtehude-Mölln</familyname>
   * <givenname>Heribert</givenname> <prefix>von und zu</prefix> <title>König</title> </author>
   * <author> <familyname>Müller</familyname> <givenname>Peter</givenname> </author> </authors>
   *
   * @param authors
   * @return
   */
  public static Node parseAsNode(String authors) {
    DocumentBuilder documentBuilder;

    try {
      documentBuilder = DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    Document document = documentBuilder.newDocument();
    Element element = document.createElement("authors");
    document.appendChild(element);

    try {
      AuthorDecoder authorDecoder = new AuthorDecoder(authors);
      List<Author> authorList = authorDecoder.getBestAuthorList();
      if (authorList != null) {
        for (Author author : authorList) {
          Element authorElement = document.createElement("author");
          element.appendChild(authorElement);

          if (author.getSurname() != null) {
            Element familyNameElement = document.createElement("familyname");
            familyNameElement.setTextContent(author.getSurname());
            authorElement.appendChild(familyNameElement);
          }

          if (author.getGivenName() != null) {
            Element givenNameElement = document.createElement("givenname");
            givenNameElement.setTextContent(author.getGivenName());
            authorElement.appendChild(givenNameElement);
          }

          if (author.getPrefix() != null) {
            Element prefixElement = document.createElement("prefix");
            prefixElement.setTextContent(author.getPrefix());
            authorElement.appendChild(prefixElement);
          }

          if (author.getTitle() != null) {
            Element titleElement = document.createElement("title");
            titleElement.setTextContent(author.getTitle());
            authorElement.appendChild(titleElement);
          }
        }
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return document;
  }
 /** @param args */
 public static void main(String[] args) throws Exception {
   // System.out.println(new LooseFormatSurnameFirst().getPattern());
   /*
    * String[] prefixes1 = "Damien van den Borgne".split(WesternFormat1.PREFIX, 3); String[]
    * prefixes2 = "Damien von Sudo".split(WesternFormat1.PREFIX, 3);
    *
    * for (String string : prefixes1) { System.out.println(string); }
    *
    * for (String string : prefixes2) { System.out.println(string); }
    */
   if (args == null || args.length == 0) {
     System.out.println("usage: java de.mpg.escidoc.services.util.AuthorDecoder author_string");
     System.out.println("Please make sure your classpath points to a valid log4j configuration.");
   } else {
     AuthorDecoder authorDecoder = new AuthorDecoder(args[0]);
     authorDecoder.displayAuthors();
   }
 }