我希望从XML呈现一些静态应用程序页面,即我计划有一个基页和xml包含页面结构和xslt,它将把这个xml转换为html,在运行时我会渲染这个html在我看来并显示这个视图 做同样的事情/例子吗?请帮忙 这是示例xml
<!DOCTYPE html>
<html>
<head>
<title>Create</title>
<script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript" />
<link href="/Content/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-ui.js" type="text/javascript" />
<script src="/Scripts/jquery.validate.min.js" type="text/javascript" />
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript" />
<script src="/Scripts/jquery.unobtrusive-ajax.js" type="text/javascript" />
</head>
<body>
<div id="menucontainer">
<ul id="menu">
<li>
<a href="/">Rutu</a>
</li>
<li>
<a href="/Employee">Employee</a>
</li>
</ul>
</div>
<h2>Create</h2>
<script src="/Scripts/jquery.validate.min.js" type="text/javascript" />
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript" />
<form action="/Employee/Create" method="post">
<fieldset>
<legend>EmployeeDetailsModel</legend>
<div class="editor-label">
<label for="EmpName">EmpName</label>
</div>
<div class="editor-field">
<input class="text-box single-line" id="EmpName" name="EmpName" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="EmpName" data-valmsg-replace="true" />
</div>
<div class="editor-label">
<label for="DeptId">DeptId</label>
</div>
<div class="editor-field">
<input class="text-box single-line" data-val="true" data-val-number="The field DeptId must be a number." data-val-required="The DeptId field is required." id="DeptId" name="DeptId" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="DeptId" data-valmsg- replace="true" />
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
</form>
<div>
<a href="/Employee">Back to List</a>
</div>
答案 0 :(得分:0)
MvcContrib项目提供了一个基于XSLT的视图引擎http://mvccontrib.codeplex.com/releases - 我建议你查看它。
答案 1 :(得分:0)
有一个good blog post here描述了如何创建HTML Helper以在视图中呈现XSLT。您只需从视图中调用辅助类,并在路径中传递XSLT和XML。我修改了这个帮助器,以便您也可以将XSLT和XML作为字符串传递,以获得相同的结果。