WireMock-Net / WireMock.Net

WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Apache License 2.0
1.35k stars 197 forks source link

XML transformation #1121

Open rmeshksar opened 1 week ago

rmeshksar commented 1 week ago

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.

StefH commented 2 days ago

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 commented 2 days ago

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

StefH commented 1 day ago

@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.