Asp.NET에서 XML에 XSLT를 적용 :내가 정의 ActionResult를 사용하여 컨트롤러 액션에서 XML을 반환하고있어 MVC
public class XmlActionResult : ActionResult
{
/// <summary>
/// This class is a custom ActionResult that outputs the content of an XML document to the response stream
/// </summary>
private readonly XDocument _document;
public Formatting Formatting { get; set; }
public string MimeType { get; set; }
public XmlActionResult(XDocument document)
{
_document = document;
MimeType = "text/xml";
Formatting = Formatting.None;
}
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.Clear();
context.HttpContext.Response.ContentType = MimeType;
using(var writer = new XmlTextWriter(context.HttpContext.Response.OutputStream, null)
{
Formatting = Formatting
})
_document.WriteTo(writer);
}
}
이것은 브라우저에 XML 트리를 출력합니다. XML을 변환하는 XSL 파일이 있는데 XML 출력에 스타일 시트를 적용하려면 어떻게해야합니까?
"ASP.NET MVC"는 단순히 "MVC"로 언급하지 마십시오. 하나는 프레임 워크이고 다른 하나는 언어에 독립적 인 디자인 패턴입니다. 그것은 IE와 같은 것입니다 - "인터넷" –
그건 공정한 지적입니다, 사과! –
서버 또는 클라이언트 브라우저에서 XSLT 변환을 어디에서 적용 하시겠습니까? –