WireMock.Net icon indicating copy to clipboard operation
WireMock.Net copied to clipboard

XML transformation

Open rmeshksar opened this issue 1 year ago • 3 comments

Hi, Consider this xml in the body of a request:

<People>
  <Person FirstName="John" LastName="Doe" />
  <Person FirstName="Jane" LastName="Doe" />
</People>

In response, how can I transform it to:

<All>
  <Employee FullName="John Doe"></Employee>
  <Employee FullName="Jane Doe"></Employee>
</All>

Basically I want to loop in nodes "//Person" and for each item use that node to generate response node using XPath selector on the request node.

I looked at the examples here but none of them worked in this case: https://github.com/Handlebars-Net/Handlebars.Net.Helpers/blob/2c22f91293b2cbcb94c0c39906b0393fc7969b9c/test/Handlebars.Net.Helpers.Tests/Templates/XPathPathHelpersTemplateTests.cs

Thanks.

rmeshksar avatar Jun 18 '24 12:06 rmeshksar

It is possible, but I don't know the answer.

For this scenario, XSLT transformation would be a better choice. However, that's not yet implemented in Handlebars.Net

StefH avatar Jun 26 '24 17:06 StefH

https://github.com/Handlebars-Net/Handlebars.Net.Helpers/pull/99

StefH avatar Jun 27 '24 12:06 StefH

@rmeshksar I've released a preview for WireMock.Net : 1.5.59-ci-18848 (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions) which can transform xml using xslt.

StefH avatar Jun 28 '24 06:06 StefH

@rmeshksar Did you have time to review this?

StefH avatar Jul 02 '24 08:07 StefH

https://github.com/WireMock-Net/WireMock.Net/pull/1128

StefH avatar Jul 03 '24 15:07 StefH

Thanks so much and sorry that I did not notice this to respond in time, I will try it.

rmeshksar avatar Jul 04 '24 11:07 rmeshksar

It's not yet in master, but you can try preview 1.5.59-ci-18865

StefH avatar Jul 05 '24 06:07 StefH