How to add xsl stylesheet node to XML created by XmlSerializer?

I have a WCF REST service that returns objects serialized using XmlSerializer. How can I add XSL stylesheet information (such as the one below) to the output returned by the WCF service?

<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="transforms/Customer.xsl"?> <Customer> <Name>Foo</Name> </Customer> 

My current work contract:

  [OperationContract, XmlSerializerFormat]
 [WebGet (UriTemplate = "{id}")]
 Customer GetById (string id);

What I would like to do to control the link to the stylesheet:

  [OperationContract, XmlSerializerFormat]
 [XslStylesheet (Href = "transforms / Customer.xsl")]
 [WebGet (UriTemplate = "{id}")]
 Customer GetById (string id);
+6
rest web-services xslt wcf
source share
1 answer

This article describes how to enter the [IncludeXmlDeclaration] attribute. You should have something similar for your XslStylesheet attribute.

+3
source share

All Articles