Skip to main content
Question

Processing a List of Unknown Length

  • April 28, 2017
  • 2 replies
  • 55 views

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?

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

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

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


takashi
Celebrity
  • April 28, 2017

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