Solved

xfMap error handling

  • 28 March 2018
  • 3 replies
  • 3 views

Hello,
I have a complex xml file and have created a xfMap to translate it. However the reader terminated the whole process when it failed to translate one feature due to it doesn't have the required geometry info (Line0008 as in the code below).

I'm wondering if there's a way in xfMap to handle errors by using something like try...catch or if..else. Or should I validate and fix the invalid features using something like xmlvalidator and updator before translating it using xfMap? thank you.

<PlanFeature name="Line0007">
<CoordGeom>
<Line oID="Line0007_0001">
<Start pntRef="TPS0021">5813350.321246 317541.885870 2.430529</Start>
<End pntRef="TPS0022">5813350.289701 317542.164240 2.460172</End>
</Line>
<Line oID="Line0007_0002">
<Start pntRef="TPS0022">5813350.289701 317542.164240 2.460172</Start>
<End pntRef="TPS0023">5813349.458068 317542.315624 2.497628</End>
</Line>
</CoordGeom>
</PlanFeature>
<PlanFeature name="Line0008">
<CoordGeom>
</CoordGeom>
</PlanFeature>
<PlanFeature name="Line0009">
<CoordGeom>
<Line oID="Line0009_0001">
<Start pntRef="TPS0026">5813350.052782 317541.979199 1.909791</Start>
<End pntRef="TPS0027">5813349.995435 317542.152410 1.892067</End>
</Line>
</CoordGeom>
icon

Best answer by takashi 28 March 2018, 18:29

View original

3 replies

Userlevel 2
Badge +17

Hi @sealjackii, I'm not sure if it's possible with xfMap, but you can remove PlanFeature elements which have no geometry elements with an XML transformer. For example, in this XMLUpdater configuration, the first expression removes "CoordGeom" elements having no "Line" child elements, then the second expression removes "PlanFeature" elements having no "CoordGeom" child elements

0684Q00000ArKhrQAF.png

XML Path for Deleting Elements

//CoordGeom[fn:count(child::Line) < 1]
//PlanFeature[fn:count(child::CoordGeom) < 1]
Userlevel 2
Badge +17

Hi @sealjackii, I'm not sure if it's possible with xfMap, but you can remove PlanFeature elements which have no geometry elements with an XML transformer. For example, in this XMLUpdater configuration, the first expression removes "CoordGeom" elements having no "Line" child elements, then the second expression removes "PlanFeature" elements having no "CoordGeom" child elements

0684Q00000ArKhrQAF.png

XML Path for Deleting Elements

//CoordGeom[fn:count(child::Line) < 1]
//PlanFeature[fn:count(child::CoordGeom) < 1]
Addition. This single expression should work as well.

 

//PlanFeature[fn:count(descendant::Line) < 1]

0684Q00000ArMVjQAN.png

 

Hi @sealjackii, I'm not sure if it's possible with xfMap, but you can remove PlanFeature elements which have no geometry elements with an XML transformer. For example, in this XMLUpdater configuration, the first expression removes "CoordGeom" elements having no "Line" child elements, then the second expression removes "PlanFeature" elements having no "CoordGeom" child elements

0684Q00000ArKhrQAF.png

XML Path for Deleting Elements

//CoordGeom[fn:count(child::Line) < 1]
//PlanFeature[fn:count(child::CoordGeom) < 1]
Thanks a lot Takashi, your suggestion sounds like the solution. cheers.

Reply