Skip to main content

Hi, I hope someone can help:

I have an XML URL.

The URL is updated from my reader with different variables.

  • I go through the AttributeManager to stitch together the different URL's I need to go through.
  • I input that result into the FeatureReader
  • When I go the the FeatureReaders parameters and choose elements to match, I see this:image
  • If I take the URL the FeatureReader receives as an input and paste it into a browser, it works
  • If I take the working URL and hardcode the value directly into the AttributeManager, without any variables, the FeatureReader gives me the same error
  • If I paste the working URL directly into the dataset within the feature reader I get access to the parameters and can set the Elements to Match, but that won't make it updateable from the features coming in.

To me it seems like I can't use an attribute with the URL as a dataset on an XML URL in the FeatureReader.

 

Does anyone know how to use an attribute calculated from the input data to get the information out of an XML?

 

A little more info ;-)

I'm trying to calculate public transportation time from multiple locations to one location. The standard format is XML, but could also be JSON. I have no issues getting the information out from JSON, however the structure of JSON is delivered in seems to be almost impossible to sort out, since everything coming in needs to be exposed. I can only see that I can expose attributes manually, and since it's an updated value I can't expose the attributes beforehand.

The data could deliver multiple trip options.

That ways I could choose to always expose the first one coming in, but underneath that I have a new array, showing all the different options to go through. walk 500 m; take the bus; Take the train, etc.

I need to calculate the travel time, meaning I will need know how many changes the trip makes to find the last leg in the array and calculate the total traveltime, to expose that. but that is a variable from trip to trip.

 

I have now issues with XML, since it's already exposed.

 

Thank you 🙂

 

Multiple ways to do this.

Configure the FeatureReader dynamic.

  • Hard code the Dataset.
  • Set Elements to Match.
  • Set Output Ports to Single Output Port.
  • Run the workspace with FeatureCaching on.
  • Connect the <Generic> output port to an AttributeExposer.
  • In the AttributeExposer, Import from FeatureCache.
  • Change the FeatureReaders Dataset to attribute.

 

Use a HTTPCaller to do the request, parse the XML using an XMLFragmenter.

  • Open the XMLFragmenter.
  • Point to a sample XML file.
  • Configure the Elements to Match.
  • Under Flatten Options, check Enable Flattening.
  • Run the workspace with FeatureCaching on.
  • Connect the Fragments output port to an AttributeExposer.
  • In the AttributeExposer, Import from FeatureCache.
  • Change the XMLFragmenters inout to attribute.

Thank you for your time and answer Niels.

As soon as I change it back to the attribute, it fails.

However, I can't see that it could work. The attributes I add in the Attribute Exposer are not static. Right now I'm only running on 5 test trips, when done, it could be 1000, and it could be on multiple datasets depending on the job. This will require I rebuild the Workspace for each project. Rebuild the FeatureCache right? My XML test document and/or URL can't know the features in the next trip coming in. If that make sense?

 

The situation is that one input can have different numbers of trips, but the hardest part is, that it can have different numbers of legs.

For example in trip 0 I would need the Origin.time one Leg(0) and the destination time in leg(4)

imageTo:

imageWhile another could have the final destination time in Leg(5) or leg(6)

imageSo beforehand I don't know the length of the list.

 

I hope it make sense, and I would be happy to know if I'm completely wrong :-)

 

Thanks.

 


Thank you for your time and answer Niels.

As soon as I change it back to the attribute, it fails.

However, I can't see that it could work. The attributes I add in the Attribute Exposer are not static. Right now I'm only running on 5 test trips, when done, it could be 1000, and it could be on multiple datasets depending on the job. This will require I rebuild the Workspace for each project. Rebuild the FeatureCache right? My XML test document and/or URL can't know the features in the next trip coming in. If that make sense?

 

The situation is that one input can have different numbers of trips, but the hardest part is, that it can have different numbers of legs.

For example in trip 0 I would need the Origin.time one Leg(0) and the destination time in leg(4)

imageTo:

imageWhile another could have the final destination time in Leg(5) or leg(6)

imageSo beforehand I don't know the length of the list.

 

I hope it make sense, and I would be happy to know if I'm completely wrong :-)

 

Thanks.

 

Hard to say without sample data, but in general you would fragment first on trip, then on leg and work from there. If you can add a sample we can try to parse it.


Reply