Skip to main content
<?xml version="1.0" encoding="utf-8"?>
<SDDOT>
  <item>...</item>
  <item>
    <id>497751</id>
    <status>active</status>
    <categories>
      <category>
        <name>conditions</name>
      </category>
    </categories>
    <descriptions>
      <description>
        <phrase>dry</phrase>
      </description>
    </descriptions>
    <locations>
      <location>
        <route>US-212</route>
        <direction>Both Directions</direction>
        <start>
          <lat>45.0056</lat>
          <lon>-102.8765</lon>
          <milepost>71.713</milepost>
          <landmark>
            <place>Mud Butte</place>
          </landmark>
        </start>
        <end>
          <lat>45.0231</lat>
          <lon>-102.0451</lon>
          <milepost>112.715</milepost>
          <landmark>
            <place>Junction South Dakota 73 South-Faith</place>
          </landmark>
        </end>
      </location>
      <location>
        <route>SD-73</route>
        <direction>Both Directions</direction>
        <start>
          <lat>45.0231</lat>
          <lon>-102.0451</lon>
          <milepost>166.445</milepost>
          <landmark>
            <place>Junction US 212 East-Faith</place>
          </landmark>
        </start>
        <end>
          <lat>45.0231</lat>
          <lon>-102.1095</lon>
          <milepost>169.608</milepost>
          <landmark>
            <place>Junction US 212 West</place>
          </landmark>
        </end>
      </location>
    </locations>
    <time>
      <start>
        <unixtime>1510070857</unixtime>
        <local_time>2017-11-07T09:07:37 MST</local_time>
      </start>
      <end>
        <unixtime>1510243620</unixtime>
        <local_time>2017-11-09T09:07:00 MST</local_time>
      </end>
      <announce>
        <unixtime>1510070857</unixtime>
        <local_time>2017-11-07T09:07:37 MST</local_time>
      </announce>
      <update>
        <unixtime>1510070857</unixtime>
        <local_time>2017-11-07T09:07:37 MST</local_time>
      </update>
    </time>
  </item>
  <item>...</item>
</SDDOT>

I need to get 2 features out of this, 1 for each <location> tag. How would I go about doing that? Currently I'm parsing out on each item. It threw an error when I attempted to read in the following:

<feature-map multi-feature-construction="true">
    <mapping match="item/locations/location">
       <feature-type> <literal expr="Feature"/> </feature-type>
    </mapping>
 </feature-map>

xfmap-sd-iris.xml

 

Hi @runneals,

The attached Xfmap should get you the locations with the attributes you want:

locations-xfmap.xml

Alternatively, you can use the Feature Paths Configuration Type in the XML reader read the locations from that XML data:

Enable Flattening to get the attributes:

The Feature paths is not as powerful as an Xfmap, but it is a lot simpler to use.


Hi @runneals,

The attached Xfmap should get you the locations with the attributes you want:

locations-xfmap.xml

Alternatively, you can use the Feature Paths Configuration Type in the XML reader read the locations from that XML data:

Enable Flattening to get the attributes:

The Feature paths is not as powerful as an Xfmap, but it is a lot simpler to use.

Is there any way to get the attributes outside of the locations path?
Is there any way to get the attributes outside of the locations path?
The easiest way to do that is to use the Feature Paths with Elements to Match set to 'SDDOT/item'. This will produce a single feature for each item with the locations as a list. Use a ListExploder to explode the locations.location{} list.

 

 

If you really need to use an Xfmap, I am attaching a modified copy of xfmap-sd-iris.xml that will also create a list for the locations. In the workspace, add a ListExploder to explode the list location{}.

 

location-list-xfmap.xml

 

 


Hi @runneals,

The attached Xfmap should get you the locations with the attributes you want:

locations-xfmap.xml

Alternatively, you can use the Feature Paths Configuration Type in the XML reader read the locations from that XML data:

Enable Flattening to get the attributes:

The Feature paths is not as powerful as an Xfmap, but it is a lot simpler to use.

Thanks! I need to go outside my comfort zone and parse xml besides using xfmap

Reply