Skip to main content
Question

Processing a List of Unknown Length


Forum|alt.badge.img

I am given the following XML document:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Line>
   <Segments>
        <Segment>
            <LineGeometry srid="4326">x_1,y_1;x_2,y_2;...</LineGeometry>
            <SegmentProperties>
		...
	    </SegmentProperties>
        </Segment>
        <Segment>
            <LineGeometry srid="4326">x_1,y_1;x_2,y_2;...</LineGeometry>
            <SegmentProperties>
		...
	    </SegmentProperties>
        </Segment>
	...
   </Segments>
</Line>

where each Segment should eventually create an object in Smallworld. The number of segments can be arbitrarily large (the number of SegmentProperties is fixed per segment).

As I need to not only process the LineGeometry, but also the SegmentProperties, I was wondering what the best design for this case is. An idea I had was the following:

  • Write the transformation for one element, declare that a custom transformer and iterate over all elements via a loop

Or is there a better way? I have never yet tried to implement something like that, so I wonder if that's the right way. Could PythonCaller be a better idea?

 

And is there a way to tell StringReplacer to iterate over all elements? If I want to manipulate all LineGeometry-strings, I need to select elements from 0 to X. Can I insert "ALL" somehow?

2 replies

itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • April 28, 2017

You can explode all the list elements and aggregate them accordingly before inserting them into the GML.


takashi
Supporter
  • April 28, 2017

Unclear what the goal is, but probably the XMLFragmenter or the XMLFlattener could be a good solution.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings