private void serviceIdentification(StringBuilder str) {
    ServiceInformation servInfo = tld.getServiceInformation();

    str.append("<ows:ServiceIdentification>\n");

    if (servInfo != null) {
      appendTag(str, "  ", "ows:Title", servInfo.getTitle(), "Web Map Tile Service - GeoWebCache");
      appendTag(str, "  ", "ows:Abstract", servInfo.getDescription(), null);

      if (servInfo != null && servInfo.getKeywords() != null) {
        str.append("  <ows:Keywords>\n");
        Iterator<String> keywordIter = servInfo.getKeywords().iterator();
        while (keywordIter.hasNext()) {
          appendTag(str, "    ", "ows:Keyword", keywordIter.next(), null);
        }
        str.append("  </ows:Keywords>\n");
      }
    } else {
      str.append("  <ows:Title>Web Map Tile Service - GeoWebCache</ows:Title>\n");
    }

    str.append("  <ows:ServiceType>OGC WMTS</ows:ServiceType>\n");
    str.append("  <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>\n");

    if (servInfo != null) {
      appendTag(str, "  ", "ows:Fees", servInfo.getFees(), null);
      appendTag(str, "  ", "ows:AccessConstraints", servInfo.getAccessConstraints(), null);
    }

    str.append("</ows:ServiceIdentification>\n");
  }
  private void serviceContact(StringBuilder str) {
    ServiceInformation servInfo = tld.getServiceInformation();
    if (servInfo == null) {
      return;
    }

    ServiceProvider servProv = servInfo.getServiceProvider();
    if (servProv == null) {
      return;
    }

    ServiceContact servCont = servProv.getServiceContact();

    str.append("  <ContactInformation>\n");

    if (servProv.getProviderName() != null || servCont != null) {
      str.append("    <ContactPersonPrimary>\n");
      if (servCont != null) {
        str.append("      <ContactPerson>" + servCont.getIndividualName() + "</ContactPerson>\n");
      }
      str.append(
          "      <ContactOrganization>" + servProv.getProviderName() + "</ContactOrganization>\n");
      str.append("    </ContactPersonPrimary>\n");

      if (servCont != null) {
        str.append("    <ContactPosition>" + servCont.getPositionName() + "</ContactPosition>\n");

        str.append("    <ContactAddress>\n");
        str.append("      <AddressType>" + servCont.getAddressType() + "</AddressType>\n");
        str.append("      <Address>" + servCont.getAddressStreet() + "</Address>\n");
        str.append("      <City>" + servCont.getAddressCity() + "</City>\n");
        str.append(
            "      <StateOrProvince>"
                + servCont.getAddressAdministrativeArea()
                + "</StateOrProvince>\n");
        str.append("      <PostCode>" + servCont.getAddressPostalCode() + "</PostCode>\n");
        str.append("      <Country>" + servCont.getAddressCountry() + "</Country>\n");
        str.append("    </ContactAddress>\n");
        str.append(
            "    <ContactVoiceTelephone>"
                + servCont.getPhoneNumber()
                + "</ContactVoiceTelephone>\n");
        str.append("    <ContactFacsimileTelephone>")
            .append(servCont.getFaxNumber())
            .append("</ContactFacsimileTelephone>\n");
        str.append(
            "    <ContactElectronicMailAddress>"
                + servCont.getAddressEmail()
                + "</ContactElectronicMailAddress>\n");
      }
    }

    str.append("  </ContactInformation>\n");
  }
  private void serviceProvider(StringBuilder str) {
    ServiceInformation servInfo = tld.getServiceInformation();
    ServiceProvider servProv = null;
    if (servInfo != null) {
      servProv = servInfo.getServiceProvider();
    }
    str.append("<ows:ServiceProvider>\n");

    if (servProv != null) {
      appendTag(str, "  ", "ows:ProviderName", servProv.getProviderName(), null);

      if (servProv.getProviderSite() != null) {
        appendXlink(str, "  ", "ows:ProviderSite", servProv.getProviderSite());
      }

      ServiceContact servCont = servProv.getServiceContact();
      if (servCont != null) {
        str.append("  <ows:ServiceContact>\n");
        appendTag(str, "    ", "ows:IndividualName", servCont.getIndividualName(), null);
        appendTag(str, "    ", "ows:PositionName", servCont.getPositionName(), null);
        str.append("    <ows:ContactInfo>\n");

        if (servCont.getPhoneNumber() != null || servCont.getFaxNumber() != null) {
          str.append("      <ows:Phone>\n");
          appendTag(str, "      ", "ows:Voice", servCont.getPhoneNumber(), null);
          appendTag(str, "      ", "ows:Facsimile", servCont.getFaxNumber(), null);
          str.append("      </ows:Phone>\n");
        }

        str.append("      <ows:Address>\n");
        appendTag(str, "      ", "ows:DeliveryPoint", servCont.getAddressStreet(), null);
        appendTag(str, "      ", "ows:City", servCont.getAddressCity(), null);
        appendTag(
            str, "      ", "ows:AdministrativeArea", servCont.getAddressAdministrativeArea(), null);
        appendTag(str, "      ", "ows:PostalCode", servCont.getAddressPostalCode(), null);
        appendTag(str, "      ", "ows:Country", servCont.getAddressCountry(), null);
        appendTag(str, "      ", "ows:ElectronicMailAddress", servCont.getAddressEmail(), null);
        str.append("      </ows:Address>\n");

        str.append("    </ows:ContactInfo>\n");
        str.append("  </ows:ServiceContact>\n");
      }
    } else {
      appendTag(str, "  ", "ows:ProviderName", baseUrl, null);
      appendXlink(str, "  ", "ows:ProviderSite", baseUrl);
      str.append("  <ows:ServiceContact>\n");
      appendTag(str, "    ", "ows:IndividualName", "GeoWebCache User", null);
      str.append("  </ows:ServiceContact>\n");
    }

    str.append("</ows:ServiceProvider>\n");
  }
  private void service(StringBuilder str) {
    ServiceInformation servInfo = tld.getServiceInformation();
    str.append("<Service>\n");
    str.append("  <Name>OGC:WMS</Name>\n");

    if (servInfo == null) {
      str.append("  <Title>Web Map Service - GeoWebCache</Title>\n");
    } else {
      str.append("  <Title>" + servInfo.getTitle() + "</Title>\n");
      str.append("  <Abstract>" + servInfo.getDescription() + "</Abstract>\n");

      if (servInfo.getKeywords() != null) {
        str.append("  <KeywordList>\n");
        Iterator<String> keywordIter = servInfo.getKeywords().iterator();
        while (keywordIter.hasNext()) {
          str.append("    <Keyword>" + keywordIter.next() + "</Keyword>\n");
        }
        str.append("  </KeywordList>\n");
      }
    }

    str.append(
        "  <OnlineResource xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:type=\"simple\" xlink:href=\""
            + urlStr
            + "\"/>\n");

    serviceContact(str);

    if (servInfo != null) {
      str.append("  <Fees>" + servInfo.getFees() + "</Fees>\n");
      str.append(
          "  <AccessConstraints>" + servInfo.getAccessConstraints() + "</AccessConstraints>\n");
    }

    str.append("</Service>\n");
  }