si", "http://www.w3.org/2001/XMLSchema-instance" );
	if (defined ( "INSPIRE_METADATA_SPEC" ) && INSPIRE_METADATA_SPEC!= "") {
		switch (INSPIRE_METADATA_SPEC) {
			case "2.0.1" :
				$MD_Metadata->setAttribute ( "xmlns:gmx", "http://www.isotc211.org/2005/gmx" );
				break;
		}
	}
	// $MD_Metadata->setAttribute("xsi:schemaLocation", "http://www.isotc211.org/2005/gmd./xsd/gmd/gmd.xsd http://www.isotc211.org/2005/srv./xsd/srv/srv.xsd");
	$MD_Metadata->setAttribute ( "xsi:schemaLocation", "http://www.isotc211.org/2005/gmd http://schemas.opengis.net/csw/2.0.2/profiles/apiso/1.0.0/apiso.xsd" );
	
	// generate identifier part
	$identifier = $iso19139->createElement ( "gmd:fileIdentifier" );
	$identifierString = $iso19139->createElement ( "gco:CharacterString" );
	// How to generate UUIDs for INSPIRE Download Service Metadata records (not really needed for INSPIRE!!! See DB Metadata)
	// 8-4-4-4-12
	// dataurl
	// LAYER uuid (8-4), Type (4) - 0001, MD uuid (4-12)
	// wfs
	// WFS uuid (8-4), MD uuid (4-4-12)
	// wmsgetmap
	// WMS uuid (8-4), Type (4) - 0002, MD uuid (4-12)
	// metadata
	// metadata uuid (8-4),hash(downloadLink) (4-12);
	
	if (isset ( $mapbenderMetadata ['serviceUuid'] ) && $mapbenderMetadata ['serviceUuid']!= '') {
		$servicePart = explode ( '-', $mapbenderMetadata ['serviceUuid'] );
		// in case of wmslayer and dataurl use layer_uuid - cause the same metadata record may be coupled with more than one layer of a service
		$mdPart = explode ( '-', $recordId );
		switch ($generateFrom) {
			case "wmslayer" :
				$dlsFileIdentifier = $servicePart [0]. "-". $servicePart [1]. "-". "0002". "-". $mdPart [3]. "-". $mdPart [4];
				break;
			case "dataurl" :
				$dlsFileIdentifier = $servicePart [0]. "-". $servicePart [1]. "-". "0001". "-". $mdPart [3]. "-". $mdPart [4];
				break;
			case "wfs" :
				$dlsFileIdentifier = $servicePart [0]. "-". $servicePart [1]. "-". $mdPart [2]. "-". $mdPart [3]. "-". $mdPart [4];
				break;
			// TODO!!!!!
			case "metadata" :
				// $dlsFileIdentifier = $servicePart[0]."-".$servicePart[1]."-".$mdPart[2]."-".$mdPart[3]."-".$mdPart[4];
				// generate hash from downloadLink
				$linkPart = md5 ( $mapbenderMetadata ['downloadLink'] );
				$dlsFileIdentifier = $mdPart [0]. "-". $mdPart [1]. "-". $mdPart [2]. "-". substr ( $linkPart, - 12, 4 ). "-". substr ( $linkPart, - 12, 12 );
				break;
		}
		$identifierText = $iso19139->createTextNode ( $dlsFileIdentifier );
	} else {
		$identifierText = $iso19139->createTextNode ( "no id found - please check if services have uuids or generate new ones!" );
	}
	$identifierString->appendChild ( $identifierText );
	$identifier->appendChild ( $identifierString );
	$MD_Metadata->appendChild ( $identifier );
	
	// generate language part B 10.3 (if available) of the inspire metadata regulation
	$language = $iso19139->createElement ( "gmd:language" );
	$languagecode = $iso19139->createElement ( "gmd:LanguageCode" );
	if (defined ( "INSPIRE_METADATA_SPEC" ) && INSPIRE_METADATA_SPEC!= "") {
		switch (INSPIRE_METADATA_SPEC) {
			case "2.0.1" :
				$languagecode->setAttribute ( "codeList", "http://www.loc.gov/standards/iso639-2/" );
				break;
			case "1.3" :
				$languagecode->setAttribute ( "codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#LanguageCode" );
				break;
		}
	} else {
		$languagecode->setAttribute ( "codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#LanguageCode" );
	}
	if (isset ( $mapbenderMetadata ['metadata_language'] )) {
		$languageText = $iso19139->createTextNode ( $mapbenderMetadata ['metadata_language'] );
		$languagecode->setAttribute ( "codeListValue", $mapbenderMetadata ['metadata_language'] );
	} else {
		$languageText = $iso19139->createTextNode ( "ger" );
		$languagecode->setAttribute ( "codeListValue", "ger" );
	}
	$languagecode->appendChild ( $languageText );
	$language->appendChild ( $languagecode );
	$language = $MD_Metadata->appendChild ( $language );
	
	// generate characterset part - first it should be utf8 ;-)
	$characterSet = $iso19139->createElement ( "gmd:characterSet" );
	$characterSetCode = $iso19139->createElement ( "gmd:MD_CharacterSetCode" );
	$characterSetCode->setAttribute ( "codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_CharacterSetCode" );
	$characterSetCode->setAttribute ( "codeListValue", "utf8" );
	$characterSet->appendChild ( $characterSetCode );
	$characterSet = $MD_Metadata->appendChild ( $characterSet );
	
	// generate MD_Scope part B 1.3 (if available)
	$hierarchyLevel = $iso19139->createElement ( "gmd:hierarchyLevel" );
	$scopecode = $iso19139->createElement ( "gmd:MD_ScopeCode" );
	$scopecode->setAttribute ( "codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_ScopeCode" );
	$scopecode->setAttribute ( "codeListValue", "service" );
	$scopeText = $iso19139->createTextNode ( "service" );
	
	$scopecode->appendChild ( $scopeText );
	$hierarchyLevel->appendChild ( $scopecode );
	$hierarchyLevel = $MD_Metadata->appendChild ( $hierarchyLevel );
	
	// iso19139 demands a hierarchyLevelName object
	$hierarchyLevelName = $iso19139->createElement ( "gmd:hierarchyLevelName" );
	$hierarchyLevelNameString = $iso19139->createElement ( "gco:CharacterString" );
	$hierarchyLevelNameText = $iso19139->createTextNode ( 'Downloaddienst' );
	$hierarchyLevelName->appendChild ( $hierarchyLevelNameString );
	$hierarchyLevelNameString->appendChild ( $hierarchyLevelNameText );
	$hierarchyLevelName = $MD_Metadata->appendChild ( $hierarchyLevelName );
	
	// Part B 10.1 responsible party for the resource
	$contact = $iso19139->createElement ( "gmd:contact" );
