Question

Fill metadata xml with data from another xml

  • 15 March 2018
  • 1 reply
  • 3 views

Badge +10

I have an xml with my metadata profile and another xml which matches my profile and have data but not all metadata elements are present.

I need to get my metadata profile filled with the metadata information in my second xml.

This is what I've done so far:

I have 2 XML readers each pointing to each xml and with "Elements to match" parameter set to MD_Metadata (the parent tag). I've set my profile xml into the Document port of an XMLUpdater transformer and my second xml into it's Update port but I don't know what to do next. What should I set in the Updates section?

EDIT: I'll try to expand my question a bit more.

On the left you see a very simplified version of my metadata structure (my master XML), and on the right you have the xml I want to obtain completing my profile with the data I actually have (center xml code).

As you can see there may be repeated xpaths, which make it a little more tricky, at least for me.

The XMLUpdater transformer seems the way to go but my limited knowledge on FME tells me that I should map every modification to my master XML in the Updates section which means 800 or 900 XPaths (it's a complex metadata structure and I have no control on the metadata elements which will get data) and that's discouraging.

There must be an easier way to deal with this. Maybe with some complex XQueries?

I've been thinking of another option. I could try to get the xml data into a JSON key-value object (still don't know how to do this), expose values as attributes and use them to populate an XML template with XMLTemplater transformer. Using the fme:get-attribute function with some extra XQuery to deal with repetitions (again I have to learn how to do this) I could have my XML template ready to use in some hours of work.

Along with some help with this I would really thank anyone who would give me a good XQuery reference as my aim is to be able to understand and build complex queries myself.

 


1 reply

Userlevel 4
Badge +25

Since you already have the empty XML structure I think you should be able to get by by using the XMLTemplater, that way you only need one reader and don't need to worry with XPaths.

There's an example of the XMLTemplater here: https://knowledge.safe.com/articles/961/xml-writing-to-custom-application-schemas-xmltempl.html

Reply