{"action":"created","comment":{"url":"https://api.github.com/repos/locationtech/geomesa/pulls/comments/38195711","id":38195711,"diff_hunk":"@@ -0,0 +1,171 @@\n+package org.locationtech.geomesa.convert.xml\n+\n+import com.typesafe.config.ConfigFactory\n+import org.junit.runner.RunWith\n+import org.locationtech.geomesa.convert.SimpleFeatureConverters\n+import org.locationtech.geomesa.convert.Transformers.EvaluationContext\n+import org.locationtech.geomesa.utils.geotools.SimpleFeatureTypes\n+import org.specs2.mutable.Specification\n+import org.specs2.runner.JUnitRunner\n+\n+@RunWith(classOf[JUnitRunner])\n+class XMLConverterTest extends Specification {\n+\n+  val sftConf = ConfigFactory.parseString(\n+    \"\"\"{ type-name = \"xmlFeatureType\"\n+      |  attributes = [\n+      |    {name = \"number\", type = \"Integer\"}\n+      |    {name = \"color\",  type = \"String\"}\n+      |    {name = \"weight\", type = \"String\"}\n+      |    {name = \"source\", type = \"String\"}\n+      |  ]\n+      |}\n+    \"\"\".stripMargin)\n+\n+  val sft = SimpleFeatureTypes.createType(sftConf)\n+  implicit val ec = new EvaluationContext(null, null)\n+\n+  \"XML Converter\" should {\n+\n+    \"parse multiple features out of a single document\" >> {\n+      val xml =\n+        \"\"\"<doc>\n+          |  <DataSource>\n+          |    <name>myxml</name>\n+          |  </DataSource>\n+          |  <Feature>\n+          |    <number>123</number>\n+          |    <color>red</color>\n+          |    <physical weight=\"127.5\" height=\"5'11\"/>\n+          |  </Feature>\n+          |  <Feature>\n+          |    <number>456</number>\n+          |    <color>blue</color>\n+              <physical weight=\"w2\" height=\"h2\"/>\n+          |  </Feature>\n+          |</doc>\n+        \"\"\".stripMargin\n+\n+      val parserConf = ConfigFactory.parseString(\n+        \"\"\"\n+          | converter = {\n+          |   type         = \"xml\"\n+          |   id-field     = \"uuid()\"\n+          |   feature-path = \"Feature\" // can be any xpath - relative to the root, or absolute\n+          |   fields = [\n+          |     // paths can be any xpath - relative to the feature-path, or absolute\n+          |     { name = \"number\", path = \"number\",           transform = \"$0::integer\" }\n+          |     { name = \"color\",  path = \"color\",            transform = \"trim($0)\" }\n+          |     { name = \"weight\", path = \"physical/@weight\", transform = \"trim($0)\" }\n+          |     { name = \"source\", path = \"/doc/DataSource/name/text()\" }\n+          |   ]\n+          | }\n+        \"\"\".stripMargin)\n+\n+      val converter = SimpleFeatureConverters.build[String](sft, parserConf)\n+      val features = converter.processInput(Iterator(xml)).toList\n+      features must haveLength(2)\n+      features.head.getAttribute(\"number\").asInstanceOf[Integer] mustEqual 123\n+      features.head.getAttribute(\"color\").asInstanceOf[String] mustEqual \"red\"\n+      features.head.getAttribute(\"weight\").asInstanceOf[String] mustEqual \"127.5\"\n+      features.head.getAttribute(\"source\").asInstanceOf[String] mustEqual \"myxml\"\n+      features(1).getAttribute(\"number\").asInstanceOf[Integer] mustEqual 456\n+      features(1).getAttribute(\"color\").asInstanceOf[String] mustEqual \"blue\"\n+      features(1).getAttribute(\"weight\").asInstanceOf[String] mustEqual \"w2\"\n+      features(1).getAttribute(\"source\").asInstanceOf[String] mustEqual \"myxml\"\n+    }\n+\n+    \"parse nested feature nodes\" >> {\n+      val xml =\n+        \"\"\"<doc>\n+          |  <DataSource>\n+          |    <name>myxml</name>\n+          |  </DataSource>\n+          |  <IgnoreMe>\n+          |    <Feature>\n+          |      <number>123</number>\n+          |      <color>red</color>\n+          |      <physical weight=\"127.5\" height=\"5'11\"/>\n+          |    </Feature>\n+          |  </IgnoreMe>\n+          |  <IgnoreMe>\n+          |    <Feature>\n+          |      <number>456</number>\n+          |      <color>blue</color>\n+          |      <physical weight=\"w2\" height=\"h2\"/>\n+          |    </Feature>\n+          |  </IgnoreMe>\n+          |</doc>\n+        \"\"\".stripMargin\n+\n+      val parserConf = ConfigFactory.parseString(\n+        \"\"\"\n+          | converter = {\n+          |   type         = \"xml\"\n+          |   id-field     = \"uuid()\"\n+          |   feature-path = \"/doc/IgnoreMe/Feature\" // can be any xpath - relative to the root, or absolute\n+          |   fields = [\n+          |     // paths can be any xpath - relative to the feature-path, or absolute\n+          |     { name = \"number\", path = \"number\",           transform = \"$0::integer\" }\n+          |     { name = \"color\",  path = \"color\",            transform = \"trim($0)\" }\n+          |     { name = \"weight\", path = \"physical/@weight\", transform = \"trim($0)\" }\n+          |     { name = \"source\", path = \"/doc/DataSource/name/text()\" }\n+          |   ]\n+          | }\n+        \"\"\".stripMargin)\n+\n+      val converter = SimpleFeatureConverters.build[String](sft, parserConf)\n+      val features = converter.processInput(Iterator(xml)).toList\n+      features must haveLength(2)\n+      features.head.getAttribute(\"number\").asInstanceOf[Integer] mustEqual 123\n+      features.head.getAttribute(\"color\").asInstanceOf[String] mustEqual \"red\"\n+      features.head.getAttribute(\"weight\").asInstanceOf[String] mustEqual \"127.5\"\n+      features.head.getAttribute(\"source\").asInstanceOf[String] mustEqual \"myxml\"\n+      features(1).getAttribute(\"number\").asInstanceOf[Integer] mustEqual 456\n+      features(1).getAttribute(\"color\").asInstanceOf[String] mustEqual \"blue\"\n+      features(1).getAttribute(\"weight\").asInstanceOf[String] mustEqual \"w2\"\n+      features(1).getAttribute(\"source\").asInstanceOf[String] mustEqual \"myxml\"\n+    }\n+\n+    \"apply xpath functions\" >> {\n+      val xml =\n+        \"\"\"<doc>\n+          |  <DataSource>\n+          |    <name>myxml</name>\n+          |  </DataSource>\n+          |  <Feature>\n+          |    <number>123</number>\n+          |    <color>red</color>\n+          |    <physical weight=\"127.5\" height=\"5'11\"/>\n+          |  </Feature>\n+          |</doc>\n+        \"\"\".stripMargin\n+\n+      val parserConf = ConfigFactory.parseString(\n+        \"\"\"\n+          | converter = {\n+          |   type         = \"xml\"\n+          |   id-field     = \"uuid()\"\n+          |   feature-path = \"Feature\" // can be any xpath - relative to the root, or absolute\n+          |   fields = [\n+          |     // paths can be any xpath - relative to the feature-path, or absolute\n+          |     { name = \"number\", path = \"number\",                   transform = \"$0::integer\" }\n+          |     { name = \"color\",  path = \"color\",                    transform = \"trim($0)\" }\n+          |     { name = \"weight\", path = \"floor(physical/@weight)\", transform = \"trim($0)\" }","path":"geomesa-convert/geomesa-convert-xml/src/test/scala/org/locationtech/geomesa/convert/xml/XMLConverterTest.scala","position":154,"original_position":154,"commit_id":"dcfc178c74d75716c3dae12dfb3d2f55739a1ba6","original_commit_id":"dcfc178c74d75716c3dae12dfb3d2f55739a1ba6","user":{"login":"elahrvivaz","id":7715322,"avatar_url":"https://avatars.githubusercontent.com/u/7715322?v=3","gravatar_id":"","url":"https://api.github.com/users/elahrvivaz","html_url":"https://github.com/elahrvivaz","followers_url":"https://api.github.com/users/elahrvivaz/followers","following_url":"https://api.github.com/users/elahrvivaz/following{/other_user}","gists_url":"https://api.github.com/users/elahrvivaz/gists{/gist_id}","starred_url":"https://api.github.com/users/elahrvivaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elahrvivaz/subscriptions","organizations_url":"https://api.github.com/users/elahrvivaz/orgs","repos_url":"https://api.github.com/users/elahrvivaz/repos","events_url":"https://api.github.com/users/elahrvivaz/events{/privacy}","received_events_url":"https://api.github.com/users/elahrvivaz/received_events","type":"User","site_admin":false},"body":"yeah, this was just an example of an xpath function. I'll change the type to double.","created_at":"2015-08-28T12:46:00Z","updated_at":"2015-08-28T12:46:00Z","html_url":"https://github.com/locationtech/geomesa/pull/677#discussion_r38195711","pull_request_url":"https://api.github.com/repos/locationtech/geomesa/pulls/677","_links":{"self":{"href":"https://api.github.com/repos/locationtech/geomesa/pulls/comments/38195711"},"html":{"href":"https://github.com/locationtech/geomesa/pull/677#discussion_r38195711"},"pull_request":{"href":"https://api.github.com/repos/locationtech/geomesa/pulls/677"}}},"pull_request":{"url":"https://api.github.com/repos/locationtech/geomesa/pulls/677","id":43545989,"html_url":"https://github.com/locationtech/geomesa/pull/677","diff_url":"https://github.com/locationtech/geomesa/pull/677.diff","patch_url":"https://github.com/locationtech/geomesa/pull/677.patch","issue_url":"https://api.github.com/repos/locationtech/geomesa/issues/677","number":677,"state":"open","locked":false,"title":"GEOMESA-900 Adding xml simple feature parser","user":{"login":"elahrvivaz","id":7715322,"avatar_url":"https://avatars.githubusercontent.com/u/7715322?v=3","gravatar_id":"","url":"https://api.github.com/users/elahrvivaz","html_url":"https://github.com/elahrvivaz","followers_url":"https://api.github.com/users/elahrvivaz/followers","following_url":"https://api.github.com/users/elahrvivaz/following{/other_user}","gists_url":"https://api.github.com/users/elahrvivaz/gists{/gist_id}","starred_url":"https://api.github.com/users/elahrvivaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elahrvivaz/subscriptions","organizations_url":"https://api.github.com/users/elahrvivaz/orgs","repos_url":"https://api.github.com/users/elahrvivaz/repos","events_url":"https://api.github.com/users/elahrvivaz/events{/privacy}","received_events_url":"https://api.github.com/users/elahrvivaz/received_events","type":"User","site_admin":false},"body":"Signed-off-by: Emilio Lahr-Vivaz <elahrvivaz@ccri.com>","created_at":"2015-08-27T17:48:20Z","updated_at":"2015-08-28T12:46:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"58fa9769c798a69c1c4e05486d2e49c43d953463","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/locationtech/geomesa/pulls/677/commits","review_comments_url":"https://api.github.com/repos/locationtech/geomesa/pulls/677/comments","review_comment_url":"https://api.github.com/repos/locationtech/geomesa/pulls/comments{/number}","comments_url":"https://api.github.com/repos/locationtech/geomesa/issues/677/comments","statuses_url":"https://api.github.com/repos/locationtech/geomesa/statuses/dcfc178c74d75716c3dae12dfb3d2f55739a1ba6","head":{"label":"elahrvivaz:fcr_convert_xml","ref":"fcr_convert_xml","sha":"dcfc178c74d75716c3dae12dfb3d2f55739a1ba6","user":{"login":"elahrvivaz","id":7715322,"avatar_url":"https://avatars.githubusercontent.com/u/7715322?v=3","gravatar_id":"","url":"https://api.github.com/users/elahrvivaz","html_url":"https://github.com/elahrvivaz","followers_url":"https://api.github.com/users/elahrvivaz/followers","following_url":"https://api.github.com/users/elahrvivaz/following{/other_user}","gists_url":"https://api.github.com/users/elahrvivaz/gists{/gist_id}","starred_url":"https://api.github.com/users/elahrvivaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elahrvivaz/subscriptions","organizations_url":"https://api.github.com/users/elahrvivaz/orgs","repos_url":"https://api.github.com/users/elahrvivaz/repos","events_url":"https://api.github.com/users/elahrvivaz/events{/privacy}","received_events_url":"https://api.github.com/users/elahrvivaz/received_events","type":"User","site_admin":false},"repo":{"id":20541167,"name":"geomesa","full_name":"elahrvivaz/geomesa","owner":{"login":"elahrvivaz","id":7715322,"avatar_url":"https://avatars.githubusercontent.com/u/7715322?v=3","gravatar_id":"","url":"https://api.github.com/users/elahrvivaz","html_url":"https://github.com/elahrvivaz","followers_url":"https://api.github.com/users/elahrvivaz/followers","following_url":"https://api.github.com/users/elahrvivaz/following{/other_user}","gists_url":"https://api.github.com/users/elahrvivaz/gists{/gist_id}","starred_url":"https://api.github.com/users/elahrvivaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elahrvivaz/subscriptions","organizations_url":"https://api.github.com/users/elahrvivaz/orgs","repos_url":"https://api.github.com/users/elahrvivaz/repos","events_url":"https://api.github.com/users/elahrvivaz/events{/privacy}","received_events_url":"https://api.github.com/users/elahrvivaz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/elahrvivaz/geomesa","description":"","fork":true,"url":"https://api.github.com/repos/elahrvivaz/geomesa","forks_url":"https://api.github.com/repos/elahrvivaz/geomesa/forks","keys_url":"https://api.github.com/repos/elahrvivaz/geomesa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elahrvivaz/geomesa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elahrvivaz/geomesa/teams","hooks_url":"https://api.github.com/repos/elahrvivaz/geomesa/hooks","issue_events_url":"https://api.github.com/repos/elahrvivaz/geomesa/issues/events{/number}","events_url":"https://api.github.com/repos/elahrvivaz/geomesa/events","assignees_url":"https://api.github.com/repos/elahrvivaz/geomesa/assignees{/user}","branches_url":"https://api.github.com/repos/elahrvivaz/geomesa/branches{/branch}","tags_url":"https://api.github.com/repos/elahrvivaz/geomesa/tags","blobs_url":"https://api.github.com/repos/elahrvivaz/geomesa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elahrvivaz/geomesa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elahrvivaz/geomesa/git/refs{/sha}","trees_url":"https://api.github.com/repos/elahrvivaz/geomesa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elahrvivaz/geomesa/statuses/{sha}","languages_url":"https://api.github.com/repos/elahrvivaz/geomesa/languages","stargazers_url":"https://api.github.com/repos/elahrvivaz/geomesa/stargazers","contributors_url":"https://api.github.com/repos/elahrvivaz/geomesa/contributors","subscribers_url":"https://api.github.com/repos/elahrvivaz/geomesa/subscribers","subscription_url":"https://api.github.com/repos/elahrvivaz/geomesa/subscription","commits_url":"https://api.github.com/repos/elahrvivaz/geomesa/commits{/sha}","git_commits_url":"https://api.github.com/repos/elahrvivaz/geomesa/git/commits{/sha}","comments_url":"https://api.github.com/repos/elahrvivaz/geomesa/comments{/number}","issue_comment_url":"https://api.github.com/repos/elahrvivaz/geomesa/issues/comments{/number}","contents_url":"https://api.github.com/repos/elahrvivaz/geomesa/contents/{+path}","compare_url":"https://api.github.com/repos/elahrvivaz/geomesa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elahrvivaz/geomesa/merges","archive_url":"https://api.github.com/repos/elahrvivaz/geomesa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elahrvivaz/geomesa/downloads","issues_url":"https://api.github.com/repos/elahrvivaz/geomesa/issues{/number}","pulls_url":"https://api.github.com/repos/elahrvivaz/geomesa/pulls{/number}","milestones_url":"https://api.github.com/repos/elahrvivaz/geomesa/milestones{/number}","notifications_url":"https://api.github.com/repos/elahrvivaz/geomesa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elahrvivaz/geomesa/labels{/name}","releases_url":"https://api.github.com/repos/elahrvivaz/geomesa/releases{/id}","created_at":"2014-06-05T20:51:54Z","updated_at":"2015-04-27T15:24:25Z","pushed_at":"2015-08-27T17:52:32Z","git_url":"git://github.com/elahrvivaz/geomesa.git","ssh_url":"git@github.com:elahrvivaz/geomesa.git","clone_url":"https://github.com/elahrvivaz/geomesa.git","svn_url":"https://github.com/elahrvivaz/geomesa","homepage":null,"size":8806,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"accumulo1.5.x/1.x"}},"base":{"label":"locationtech:master","ref":"master","sha":"aba7a46e49629c744b17eb7f39c08859ee7c34e8","user":{"login":"locationtech","id":1991411,"avatar_url":"https://avatars.githubusercontent.com/u/1991411?v=3","gravatar_id":"","url":"https://api.github.com/users/locationtech","html_url":"https://github.com/locationtech","followers_url":"https://api.github.com/users/locationtech/followers","following_url":"https://api.github.com/users/locationtech/following{/other_user}","gists_url":"https://api.github.com/users/locationtech/gists{/gist_id}","starred_url":"https://api.github.com/users/locationtech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/locationtech/subscriptions","organizations_url":"https://api.github.com/users/locationtech/orgs","repos_url":"https://api.github.com/users/locationtech/repos","events_url":"https://api.github.com/users/locationtech/events{/privacy}","received_events_url":"https://api.github.com/users/locationtech/received_events","type":"Organization","site_admin":false},"repo":{"id":13226069,"name":"geomesa","full_name":"locationtech/geomesa","owner":{"login":"locationtech","id":1991411,"avatar_url":"https://avatars.githubusercontent.com/u/1991411?v=3","gravatar_id":"","url":"https://api.github.com/users/locationtech","html_url":"https://github.com/locationtech","followers_url":"https://api.github.com/users/locationtech/followers","following_url":"https://api.github.com/users/locationtech/following{/other_user}","gists_url":"https://api.github.com/users/locationtech/gists{/gist_id}","starred_url":"https://api.github.com/users/locationtech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/locationtech/subscriptions","organizations_url":"https://api.github.com/users/locationtech/orgs","repos_url":"https://api.github.com/users/locationtech/repos","events_url":"https://api.github.com/users/locationtech/events{/privacy}","received_events_url":"https://api.github.com/users/locationtech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/locationtech/geomesa","description":"","fork":false,"url":"https://api.github.com/repos/locationtech/geomesa","forks_url":"https://api.github.com/repos/locationtech/geomesa/forks","keys_url":"https://api.github.com/repos/locationtech/geomesa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/locationtech/geomesa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/locationtech/geomesa/teams","hooks_url":"https://api.github.com/repos/locationtech/geomesa/hooks","issue_events_url":"https://api.github.com/repos/locationtech/geomesa/issues/events{/number}","events_url":"https://api.github.com/repos/locationtech/geomesa/events","assignees_url":"https://api.github.com/repos/locationtech/geomesa/assignees{/user}","branches_url":"https://api.github.com/repos/locationtech/geomesa/branches{/branch}","tags_url":"https://api.github.com/repos/locationtech/geomesa/tags","blobs_url":"https://api.github.com/repos/locationtech/geomesa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/locationtech/geomesa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/locationtech/geomesa/git/refs{/sha}","trees_url":"https://api.github.com/repos/locationtech/geomesa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/locationtech/geomesa/statuses/{sha}","languages_url":"https://api.github.com/repos/locationtech/geomesa/languages","stargazers_url":"https://api.github.com/repos/locationtech/geomesa/stargazers","contributors_url":"https://api.github.com/repos/locationtech/geomesa/contributors","subscribers_url":"https://api.github.com/repos/locationtech/geomesa/subscribers","subscription_url":"https://api.github.com/repos/locationtech/geomesa/subscription","commits_url":"https://api.github.com/repos/locationtech/geomesa/commits{/sha}","git_commits_url":"https://api.github.com/repos/locationtech/geomesa/git/commits{/sha}","comments_url":"https://api.github.com/repos/locationtech/geomesa/comments{/number}","issue_comment_url":"https://api.github.com/repos/locationtech/geomesa/issues/comments{/number}","contents_url":"https://api.github.com/repos/locationtech/geomesa/contents/{+path}","compare_url":"https://api.github.com/repos/locationtech/geomesa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/locationtech/geomesa/merges","archive_url":"https://api.github.com/repos/locationtech/geomesa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/locationtech/geomesa/downloads","issues_url":"https://api.github.com/repos/locationtech/geomesa/issues{/number}","pulls_url":"https://api.github.com/repos/locationtech/geomesa/pulls{/number}","milestones_url":"https://api.github.com/repos/locationtech/geomesa/milestones{/number}","notifications_url":"https://api.github.com/repos/locationtech/geomesa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/locationtech/geomesa/labels{/name}","releases_url":"https://api.github.com/repos/locationtech/geomesa/releases{/id}","created_at":"2013-09-30T20:13:46Z","updated_at":"2015-08-27T23:17:54Z","pushed_at":"2015-08-28T00:31:19Z","git_url":"git://github.com/locationtech/geomesa.git","ssh_url":"git@github.com:locationtech/geomesa.git","clone_url":"https://github.com/locationtech/geomesa.git","svn_url":"https://github.com/locationtech/geomesa","homepage":null,"size":22633,"stargazers_count":94,"watchers_count":94,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":60,"mirror_url":null,"open_issues_count":5,"forks":60,"open_issues":5,"watchers":94,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/locationtech/geomesa/pulls/677"},"html":{"href":"https://github.com/locationtech/geomesa/pull/677"},"issue":{"href":"https://api.github.com/repos/locationtech/geomesa/issues/677"},"comments":{"href":"https://api.github.com/repos/locationtech/geomesa/issues/677/comments"},"review_comments":{"href":"https://api.github.com/repos/locationtech/geomesa/pulls/677/comments"},"review_comment":{"href":"https://api.github.com/repos/locationtech/geomesa/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/locationtech/geomesa/pulls/677/commits"},"statuses":{"href":"https://api.github.com/repos/locationtech/geomesa/statuses/dcfc178c74d75716c3dae12dfb3d2f55739a1ba6"}}}}