{"action":"created","issue":{"url":"https://api.github.com/repos/geonetwork/core-geonetwork/issues/1448","repository_url":"https://api.github.com/repos/geonetwork/core-geonetwork","labels_url":"https://api.github.com/repos/geonetwork/core-geonetwork/issues/1448/labels{/name}","comments_url":"https://api.github.com/repos/geonetwork/core-geonetwork/issues/1448/comments","events_url":"https://api.github.com/repos/geonetwork/core-geonetwork/issues/1448/events","html_url":"https://github.com/geonetwork/core-geonetwork/issues/1448","id":134254272,"number":1448,"title":"Saving a metadata with an empty keyword value creates invalid metadata","user":{"login":"josegar74","id":1695003,"avatar_url":"https://avatars.githubusercontent.com/u/1695003?v=3","gravatar_id":"","url":"https://api.github.com/users/josegar74","html_url":"https://github.com/josegar74","followers_url":"https://api.github.com/users/josegar74/followers","following_url":"https://api.github.com/users/josegar74/following{/other_user}","gists_url":"https://api.github.com/users/josegar74/gists{/gist_id}","starred_url":"https://api.github.com/users/josegar74/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josegar74/subscriptions","organizations_url":"https://api.github.com/users/josegar74/orgs","repos_url":"https://api.github.com/users/josegar74/repos","events_url":"https://api.github.com/users/josegar74/events{/privacy}","received_events_url":"https://api.github.com/users/josegar74/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/geonetwork/core-geonetwork/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"josegar74","id":1695003,"avatar_url":"https://avatars.githubusercontent.com/u/1695003?v=3","gravatar_id":"","url":"https://api.github.com/users/josegar74","html_url":"https://github.com/josegar74","followers_url":"https://api.github.com/users/josegar74/followers","following_url":"https://api.github.com/users/josegar74/following{/other_user}","gists_url":"https://api.github.com/users/josegar74/gists{/gist_id}","starred_url":"https://api.github.com/users/josegar74/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josegar74/subscriptions","organizations_url":"https://api.github.com/users/josegar74/orgs","repos_url":"https://api.github.com/users/josegar74/repos","events_url":"https://api.github.com/users/josegar74/events{/privacy}","received_events_url":"https://api.github.com/users/josegar74/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/geonetwork/core-geonetwork/milestones/19","html_url":"https://github.com/geonetwork/core-geonetwork/milestones/3.0.4","labels_url":"https://api.github.com/repos/geonetwork/core-geonetwork/milestones/19/labels","id":1449765,"number":19,"title":"3.0.4","description":"","creator":{"login":"fxprunayre","id":1701393,"avatar_url":"https://avatars.githubusercontent.com/u/1701393?v=3","gravatar_id":"","url":"https://api.github.com/users/fxprunayre","html_url":"https://github.com/fxprunayre","followers_url":"https://api.github.com/users/fxprunayre/followers","following_url":"https://api.github.com/users/fxprunayre/following{/other_user}","gists_url":"https://api.github.com/users/fxprunayre/gists{/gist_id}","starred_url":"https://api.github.com/users/fxprunayre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fxprunayre/subscriptions","organizations_url":"https://api.github.com/users/fxprunayre/orgs","repos_url":"https://api.github.com/users/fxprunayre/repos","events_url":"https://api.github.com/users/fxprunayre/events{/privacy}","received_events_url":"https://api.github.com/users/fxprunayre/received_events","type":"User","site_admin":false},"open_issues":35,"closed_issues":19,"state":"open","created_at":"2015-12-08T12:27:38Z","updated_at":"2016-02-17T11:26:01Z","due_on":"2016-03-08T23:00:00Z","closed_at":null},"comments":2,"created_at":"2016-02-17T11:26:01Z","updated_at":"2016-02-17T13:01:29Z","closed_at":null,"body":"Creating a metadata from a template with a keyword  from Gemet thesaurus (probably doesn't matter the thesaurus):\r\n\r\n```\r\n      <gmd:descriptiveKeywords>\r\n        <gmd:MD_Keywords>\r\n          <gmd:keyword gco:nilReason=\"missing\">\r\n            <gco:CharacterString />\r\n          </gmd:keyword>\r\n          <gmd:thesaurusName>\r\n            <gmd:CI_Citation>\r\n              <gmd:title>\r\n                <gco:CharacterString>GEMET - INSPIRE themes, version 1.0</gco:CharacterString>\r\n              </gmd:title>\r\n              <gmd:date>\r\n                <gmd:CI_Date>\r\n                  <gmd:date>\r\n                    <gco:Date>2008-06-01</gco:Date>\r\n                  </gmd:date>\r\n                  <gmd:dateType>\r\n                    <gmd:CI_DateTypeCode codeList=\"http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode\" codeListValue=\"publication\" />\r\n                  </gmd:dateType>\r\n                </gmd:CI_Date>\r\n              </gmd:date>\r\n            </gmd:CI_Citation>\r\n          </gmd:thesaurusName>\r\n        </gmd:MD_Keywords>\r\n      </gmd:descriptiveKeywords>\r\n```\r\n\r\n and saving the metadata without specifying a value for the keyword, creates invalid metadata, without the gmd:keyword section :\r\n\r\n```\r\n      <gmd:descriptiveKeywords>\r\n        <gmd:MD_Keywords>\r\n          <gmd:type>\r\n            <gmd:MD_KeywordTypeCode codeList=\"http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_KeywordTypeCode\" codeListValue=\"theme\"/>\r\n          </gmd:type>\r\n          <gmd:thesaurusName>\r\n            <gmd:CI_Citation>\r\n              <gmd:title>\r\n                <gco:CharacterString>GEMET - INSPIRE themes, version 1.0</gco:CharacterString>\r\n              </gmd:title>\r\n              <gmd:date>\r\n                <gmd:CI_Date>\r\n                  <gmd:date>\r\n                    <gco:Date>2008-06-01</gco:Date>\r\n                  </gmd:date>\r\n                  <gmd:dateType>\r\n                    <gmd:CI_DateTypeCode codeList=\"http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#CI_DateTypeCode\" codeListValue=\"publication\"/>\r\n                  </gmd:dateType>\r\n                </gmd:CI_Date>\r\n              </gmd:date>\r\n              <gmd:identifier>\r\n                <gmd:MD_Identifier>\r\n                  <gmd:code>\r\n                    <gmx:Anchor xmlns:gmx=\"http://www.isotc211.org/2005/gmx\" xlink:href=\"http://localhost:8080/geonetwork/srv/eng/thesaurus.download?ref=external.theme.inspire-theme\">geonetwork.thesaurus.external.theme.inspire-theme</gmx:Anchor>\r\n                  </gmd:code>\r\n                </gmd:MD_Identifier>\r\n              </gmd:identifier>\r\n            </gmd:CI_Citation>\r\n          </gmd:thesaurusName>\r\n        </gmd:MD_Keywords>\r\n      </gmd:descriptiveKeywords>\r\n```\r\n\r\nThe problem seem in this code: \r\n\r\nhttps://github.com/geonetwork/core-geonetwork/blob/develop/services/src/main/java/org/fao/geonet/services/metadata/AjaxEditUtils.java#L185-L187\r\n\r\nxmlInputs receives the invalid snippet for the keyword."},"comment":{"url":"https://api.github.com/repos/geonetwork/core-geonetwork/issues/comments/185192183","html_url":"https://github.com/geonetwork/core-geonetwork/issues/1448#issuecomment-185192183","issue_url":"https://api.github.com/repos/geonetwork/core-geonetwork/issues/1448","id":185192183,"user":{"login":"josegar74","id":1695003,"avatar_url":"https://avatars.githubusercontent.com/u/1695003?v=3","gravatar_id":"","url":"https://api.github.com/users/josegar74","html_url":"https://github.com/josegar74","followers_url":"https://api.github.com/users/josegar74/followers","following_url":"https://api.github.com/users/josegar74/following{/other_user}","gists_url":"https://api.github.com/users/josegar74/gists{/gist_id}","starred_url":"https://api.github.com/users/josegar74/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josegar74/subscriptions","organizations_url":"https://api.github.com/users/josegar74/orgs","repos_url":"https://api.github.com/users/josegar74/repos","events_url":"https://api.github.com/users/josegar74/events{/privacy}","received_events_url":"https://api.github.com/users/josegar74/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T13:01:29Z","updated_at":"2016-02-17T13:01:29Z","body":"Previous commit fixes the missing gmd:keyword when the keyword value is empty, but still it's added this section:\r\n\r\n```\r\n              <gmd:identifier>\r\n                <gmd:MD_Identifier>\r\n                  <gmd:code>\r\n                       <gmx:Anchor xmlns:gmx=\"http://www.isotc211.org/2005/gmx\" xlink:href=\"http://localhost:8080/geonetwork/srv/eng/thesaurus.download?ref=external.theme.inspire-theme\">geonetwork.thesaurus.external.theme.inspire-theme</gmx:Anchor>\r\n                  </gmd:code>\r\n                </gmd:MD_Identifier>\r\n              </gmd:identifier>\r\n```\r\n\r\nThat seem not valid.\r\n\r\nDescription: cvc-complex-type.2.4.a: Invalid content was found starting with element '{\"http://www.isotc211.org/2005/gmx\":Anchor}'. One of '{\"http://www.isotc211.org/2005/gco\":CharacterString}' is expected.\r\n\r\nAttached a sample created with the default iso19139 template:\r\n\r\n[sample.txt](https://github.com/geonetwork/core-geonetwork/files/134295/sample.txt)\r\n\r\n@fxprunayre Any idea why is used this gmx:Anchor stuff and why doesn't validate?\r\n\r\n"}}