|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Is it possible to use xsl as a web template
Hi, when I use php templates I have one main file like tpl.php which will look like this (seriously cut down version)
PHP Code:
Then in my main pages i willl have something like PHP Code:
is it possible to set up any kind of system like this with xsl ? I tried but would not be allowed due to having opening and closing tags in diffrent sections any advice for me ? Thank Tom |
|
#2
|
|||
|
|||
|
Yes you can, XSL is perfect for use as a web template language. I have a standard Layout.xsl file, a Header.xsl, footer.xsl, Navigation.xsl which are brought together by calling an xsl:include in the page master xsl file. Each page master would look something like this:
Code:
<!-- page.master.001.xsl --> ... ... <xsl:include href="layout.xsl"/> <xsl:include href="header.xsl"/> <xsl:include href="footer.xsl"/> <xsl:include href="navigation.xsl"/> <xsl:include href="page.display.001.xsl"/> ... <xsl:call-tamplate name="PageHeader"/> <xsl:call-tamplate name="LayoutTable"/> Then inside the layout table I'd call a navigation template, logo template etc and a MainContent template which is inside page.display.001.xsl - this lets me have a series of near-identical page.master.xxx.xsl files which all use xsl:include to call the same layout templates. tamplate??? err ... sorry about that! Last edited by teedee : December 13th, 2003 at 01:07 PM. |
|
#3
|
|||
|
|||
|
Can you show me some example content ?
When i try this for my header file header.xsl Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method='xhtml' /> <xsl:template match="header"> <html> </xsl:template> </xsl:stylesheet> It returns an error XML parser error 7: mismatched tag I have to close the tag with </html> but i would want this to be in the footer template no ? |
|
#4
|
|||
|
|||
|
ok, couple of points.
First off, the method should be "xml" not "xhtml". Using a value of "xml" tells the XSL engine to close all your tags like <this/> so your output will be xml (and therefore xhtml) compliant. Second, your xsl file has to be xml-compliant with properly nested tags. The example you give isn't valid as the html tag has to be closed inside the header template. Here's a quick example ... Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="header"> <html> <xsl:call-template name="DoHeader"> <xsl:with-param name="PageTitle">Example XHTML Output</xsl:with-param> </xsl:call-template> <xsl:call-template name="DoBody"/> </html> </xsl:template> <xsl:template name="DoHeader"> <xsl:param name="PageTitle"/> <head> <title> <xsl:value-of select="$PageTitle"/> </title> </head> </xsl:template> <xsl:template name="DoBody"> This is the body! </xsl:template> </xsl:stylesheet> |
|
#5
|
|||
|
|||
|
thanks but this still would not work for me the body is goign to change on each page?!? so i would have to make another file and adding the same <html> tage again to it so if i want to change something inside the <html></html> tag i still have to open up every page...
|
|
#6
|
|||
|
|||
|
Obviously the body is going to change on each page, that's why you use different XML files for each page ...
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Is it possible to use xsl as a web template |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|