parameters: (workspace, layer, element, namespaces)
docstring: Replace workspace/layer-specific OnlineResource links with the more
      generic links returned by a site-wide GetCapabilities document
docstring_summary: Replace workspace/layer-specific OnlineResource links with the more
      generic links returned by a site-wide GetCapabilities document
docstring_tokens: Replace workspace / layer - specific OnlineResource links with the more generic links returned by a site - wide GetCapabilities document
function: def format_online_resource(workspace, layer, element, namespaces):
      """
      Replace workspace/layer-specific OnlineResource links with the more
      generic links returned by a site-wide GetCapabilities document
      """
      layerName = element.find('.//wms:Capability/wms:Layer/wms:Layer/wms:Name',
                               namespaces)
      if layerName is None:
          return
  
      layerName.text = f"{workspace}:{layer}" if workspace else layer
      layerresources = element.findall('.//wms:OnlineResource', namespaces)
      if layerresources is None:
          return
  
      for resource in layerresources:
          wtf = resource.attrib['{http://www.w3.org/1999/xlink}href']
          replace_string = f"/{workspace}/{layer}" if workspace else f"/{layer}"
          resource.attrib['{http://www.w3.org/1999/xlink}href'] = wtf.replace(
              replace_string, "")
function_tokens: def format_online_resource ( workspace , layer , element , namespaces ) : layerName = element . find ( './/wms:Capability/wms:Layer/wms:Layer/wms:Name' , namespaces ) if layerName is None : return layerName . text = f"{workspace}:{layer}" if workspace else layer layerresources = element . findall ( './/wms:OnlineResource' , namespaces ) if layerresources is None : return for resource in layerresources : wtf = resource . attrib [ '{http://www.w3.org/1999/xlink}href' ] replace_string = f"/{workspace}/{layer}" if workspace else f"/{layer}" resource . attrib [ '{http://www.w3.org/1999/xlink}href' ] = wtf . replace ( replace_string , "" )