I am working on restoring part of the user interface of our website, which is largely based on javascript / ajax (without good reason and in a rather inefficient way), so that the backend will now do most of the content generation. This is a C # .net application.
Almost all of our pages (which are probably 40-50 pages) have the same basic layout. I'm new to XSLT, but I did a lot of work with MVC frameworks such as Spring (java using Sitemesh for layout), Symfony (PHP), a few rails, as well as a few others. I like to have one or more common templates, and then have a special “content” section that contains specific material. I cannot understand how this is done with XSLT. In the case of this application, I have a value available to me in xml that supports the xslt page, which allows me to call it ContentXSL, whose value is the name of the xsl file I want to use for the page content section. I know this is not possible, but it would be nice to use:
<xsl:call-template name="{$ContentXSL}" />
Then I could just put this in the content section. However, this is not possible, so instead I will need a massive select statement that calls the correct template based on the variable ContentPage .. This also means in my layout. xsl file I would have to include all 40-50 xsl documents .. I would have thought that the overhead would be pretty big, but I'm not sure about that. Is it a sensible thing if a site gets a lot of traffic?
What are other common ways to do this? It seems that most modern frameworks allow you to use this template to decorate content. In the case of Symfony, it worked very well and was quite flexible (with slots and all that).
, , 40 , , . , , 40-50 ( ).
-
, , .
, xml, , URL- -. , , ( -, html - ).
:
<xml>
<section>Blogs</section>
<page>showAll</section>
<data>
<blogs>
<blog>
<author>somebody</author>
<title></title>
<content>..</content>
</blog>
</blog>..</blog>
</blogs>
</data>
</xml>
:
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-microsoft-com:xslt'>
<xsl:output omit-xml-declaration='yes' method='html' media-type='text/html' indent='yes' />
<xsl:include href="Header.xsl"/>
<xsl:include href="Nav.xsl"/>
<xsl:template name='MainLayout' match='*'>
<html>
<head>
<title></title>
</head>
<body>
<div id="header"><xsl:call-template name="Header" /></div>
<div id="nav"><xsl:call-template name="Nav" /></div>
<div id="content">
[here is where i want to use the xsl from {/xml/section}/{/xml/page}.xsl]
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
:
/showAll.xsl
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-microsoft-com:xslt'>
<xsl:output omit-xml-declaration='yes' method='html' media-type='text/html' indent='yes' />
<xsl:template name='Blogs_ShowAll'>
<div id="blogs-showAll">
..iterate over /xml/data/blogs converting to html
</div>
</xsl:template>
</xsl:stylesheet>
, (, , xsl xsl: , ).
, FXSL .
, sitemesh, html/body , , , , div div (, title , - ).