6

I have an WCF REST service which returns objects serialized with XmlSerializer. How can I add XSL stylesheet information (like 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 operationcontract:

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

What I would prefer to be able to do, in order to control the stylesheet reference:

[OperationContract, XmlSerializerFormat]
[XslStylesheet( Href = "transforms/Customer.xsl" )]
[WebGet( UriTemplate = "{id}" )]
Customer GetById( string id );
1
  • Did you get this working? Care to share? Commented Aug 3, 2017 at 18:31

1 Answer 1

3

This article decribes how to introduce a [IncludeXmlDeclaration] attribute. You should be able to something similar for your XslStylesheet attribute.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.