I have a source list of xml in this format:
<metadata>
<metadatum>
<description>OnEnter</description>
<value>Hello World</id>
</metadatum>
<metadatum>
<description>OnLeave</description>
<value>Goodbye World</id>
</metadatum>
</metadata>
and a target structure like this:
<friendlyText>
<onEnter>[Content Here]</onEnter>
<onLeave>[Content Here]</onLeave>
</friendlyText>
Is it possible to create an XSLT that will map the ‘value’ field in the metadata hierarchy to the proper target node depending on the source ‘description’?
I’m trying to get this done with Altova MapForce; it feels like there should be an interface to allow this, I’m just not finding it.
This transformation is a general solution that can work with any “target structure” that is in a separate XML document:
when applied on the provided XML document (corrected to be made well-formed):
produces the wanted, correct result:
Do note: Only for convenience, the “target structure” is inline here. In a real world case it would be better to keep the “target structure” in a separate file and to load it using the
document()function. Only the line:will need to be changed to: