Page 1 of 1

Advise how to swap node values for every occurrence?

Posted: Tue Sep 02, 2008 5:42 am
by jcblitz
Can anyone recommend a way to swap two node values for every occurrence of STMTTRN?

For instance:

Code: Select all

<STMTTRN>
<TRNTYPE>DEBIT</TRNTYPE>
<DTPOSTED>123</DTPOSTED>
<DTUSER>456</DTUSER>
<TRNAMT>-30.00</TRNAMT>
<FITID>987654321</FITID>
<NAME>Value A</NAME>
<MEMO>Value B</MEMO>
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT</TRNTYPE>
<DTPOSTED>456</DTPOSTED>
<DTUSER>789</DTUSER>
<TRNAMT>-50.00</TRNAMT>
<FITID>1234567890</FITID>
<NAME>Value C</NAME>
<MEMO>Value D</MEMO>
</STMTTRN>
the nodes NAME and MEMO values flip, becoming

Code: Select all

<STMTTRN>
<TRNTYPE>DEBIT</TRNTYPE>
<DTPOSTED>123</DTPOSTED>
<DTUSER>456</DTUSER>
<TRNAMT>-30.00</TRNAMT>
<FITID>987654321</FITID>
<NAME>Value B</NAME>
<MEMO>Value A</MEMO>
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT</TRNTYPE>
<DTPOSTED>456</DTPOSTED>
<DTUSER>789</DTUSER>
<TRNAMT>-50.00</TRNAMT>
<FITID>1234567890</FITID>
<NAME>Value D</NAME>
<MEMO>Value C</MEMO>
</STMTTRN>
I wanted to avoid writing a Java app to do something fairly trivial. Is there a way to do this just within Oxygen?

Re: Advise how to swap node values for every occurrence?

Posted: Tue Sep 02, 2008 9:17 am
by sorin_ristache
Hello,

I think it is easier with an XSLT stylesheet that transforms the first XML document to the second one. You can start from an identity transform (look for such a transform with Google) and add some XSLT templates to that until the stylesheet does your transformation. You apply the XSLT transform in Oxygen with a transformation scenario.


Regards,
Sorin

Re: Advise how to swap node values for every occurrence?

Posted: Tue Sep 02, 2008 3:23 pm
by jcblitz
sorin wrote:Hello,

I think it is easier with an XSLT stylesheet that transforms the first XML document to the second one. You can start from an identity transform (look for such a transform with Google) and add some XSLT templates to that until the stylesheet does your transformation. You apply the XSLT transform in Oxygen with a transformation scenario.


Regards,
Sorin
Thanks, I'll look into it. My original thought was to use XSLT but then I figured since I'm really concerned with the xml data itself, not as a datasource, that might be the wrong route.