Hi,
I'm pretty new to XSLT and have an urgent work requirement that I'm finding quite complex to sort out.
I have an XML doc which needs an attribute adding under certain conditions.
The XML doc is pretty straightforward:
<A x="foo" y="bar" z="">
<B/>
<C/></A>
Basically if attribute "z" is present. Then a new attribute needs to be added to node "A". The value of the attribute needs to be a text string with the values of "x" and "y" substituted at certain places. The result should look like:
<A x="foo" y="bar" z="" new="values present are x=foo and y=bar">
<B/>
<C/></A>
I've gotten as far as creating an XSLT that will copy the document to the attribute level. But I'm stumbling when trying to create the logic that tests for attribute z and creates a string based on x and y.
Can anyone help?
Thanks
Also - apologies if my code formatting sucks
From comments:
There's something that's stopping these solutions working. The text XML I've put above actually has a root node
<R>
that contains it all. The R node has an attribute like this :xmlns="http://www.fixprotocol.org/FIXML-4-4"
. Adding this attribute for some reason causes the template matching "A" to not work?!