Hi Jeremy,
Nope I don't get any errors. Perhaps it'll help if i try to explain
how I'm using it.
somewhere in Application_Start
...
ViewEngines.Engines.Add(new XsltViewFactory());
...
Now in my controller
...
public ViewResult Greetings(string language)
{
var greetings = new XmlDocument();
var filepath = ControllerContext.HttpContext.Server.MapPath
(FilePaths.Xml.PartnerText);
greetings.Load(filepath);
var data = new XsltViewData();
data.PageVars.Add("language", language.ToLower());
data.DataSources.Add(new XslDataSource(new XmlConvertible
(greetings)));
return View(data);
}
...
greetingtexts.xml:
<?xml version="1.0" encoding="utf-8" ?>
<greetings>
<greeting language="english">
<p>Hello...</p>
</greeting>
<greeting language="spanish">
<p>Hola...</p>
</greeting>
</greetings>
greetings.xslt:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/
Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-
prefixes="msxsl">
<xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0
Strict//EN" media-type="application/html+xml" encoding="utf-8" omit-
xml-declaration="yes" indent="no"/>
<xsl:param name="language"></xsl:param>
<xsl:template match="/">
Selected language: <xsl:value-of select="$language"/>
<xsl:copy-of select="//*[@language=$language]/*"/>
</xsl:template>
</xsl:stylesheet>
So the xslt view engine will find the xslt file with the same name as
the action (just like with the normal views unless specified
otherwise) and transform it with the given xml file. I think that's
about it. Also, I misinformed when i said it wasn't rendering, I
meant it wasn't transforming correctly. In the example I gave, all
that shows up is "Selected language", but what you should see if you
pass in the parameter of "english" is "Selected language: english
<p>Hello...</p>".
Again this was working in a version prior to mvc2, I was wondering if
there were some changes i needed to make now with the update.
Much Thanks,
Amy
On Oct 28, 1:59 pm, Jeremy Skinner <
jer...@jeremyskinner.co.uk> wrote:
> Hi Amy,
>
> I'm not very familiar with the XsltViewEngine, but I just tried putting
> together a simple MVC2 project and it worked correctly. Are you getting an
> error message?
>
> Jeremy
>
> 2009/10/28 amyto <
amyt...@gmail.com>