XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 12th, 2003, 04:54 PM
TomWestcott TomWestcott is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: England
Posts: 19 TomWestcott User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 13 sec
Reputation Power: 0
Send a message via ICQ to TomWestcott Send a message via AIM to TomWestcott
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:
function htmlheader()
{
  echo 
"<html>";
}
function 
htmlFooter()
{
  echo 
"</html>



Then in my main pages i willl have something like

PHP Code:
 htmlHeader();
echo 
"somecontent"
htmlFooter(); 


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

Reply With Quote
  #2  
Old December 13th, 2003, 06:48 AM
teedee teedee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 42 teedee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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.

Reply With Quote
  #3  
Old December 13th, 2003, 10:17 AM
TomWestcott TomWestcott is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: England
Posts: 19 TomWestcott User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 13 sec
Reputation Power: 0
Send a message via ICQ to TomWestcott Send a message via AIM to TomWestcott
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 ?

Reply With Quote
  #4  
Old December 13th, 2003, 01:03 PM
teedee teedee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 42 teedee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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>

Reply With Quote
  #5  
Old December 13th, 2003, 06:17 PM
TomWestcott TomWestcott is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: England
Posts: 19 TomWestcott User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 13 sec
Reputation Power: 0
Send a message via ICQ to TomWestcott Send a message via AIM to TomWestcott
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...

Reply With Quote
  #6  
Old December 14th, 2003, 03:28 AM
teedee teedee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 42 teedee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Obviously the body is going to change on each page, that's why you use different XML files for each page ...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Is it possible to use xsl as a web template


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT