XSLT one tamplate opens tag second template closes - newbie

R

R

Hello everybody.

I've got a problem with creating a universal stylesheet eg:

<xsl:template match="/">
<xsl:call-template name="header"/>
<xsl:apply-templates select="/data/content"/>
<xsl:call-template name="footer"/>
</xsl:template>

inside header tamplate I've got sth like this:

<xsl:template name="header">
<html>
<head>
<title>
<xsl:value-of select="$Title"/>
</title>
</head>
<body>
</xsl:template>

as You can see the html and body tags are open...

and the footer template would print some additional info and would
close:
</body> and </html>

it is of course not well-formed document and won't compile

but for sure it can be omitted somehow, many of You probably use
similar constructions

thanks in advance for Your help
best regards R
 
J

Joris Gillis

Tempore 15:38:52 said:
I've got a problem with creating a universal stylesheet eg:

<xsl:template match="/">
<xsl:call-template name="header"/>
<xsl:apply-templates select="/data/content"/>
<xsl:call-template name="footer"/>
</xsl:template>

inside header tamplate I've got sth like this:

<xsl:template name="header">
<html>
<head>
<title>
<xsl:value-of select="$Title"/>
</title>
</head>
<body>
</xsl:template>

as You can see the html and body tags are open...

and the footer template would print some additional info and would
close:
</body> and </html>
Hi,

Try to think in terms of tree output instead of sequential output when you're making XSL.
Just restructure it so that it is well-formed and makes more sence. e.g. :

<xsl:template match="/">
<html>
<head>
<xsl:call-template name="header"/>
</head>
<body>
<xsl:apply-templates select="/data/content"/>
<xsl:call-template name="footer"/>
</body>
</html>
</xsl:template>

<xsl:template name="header">
<title>
<xsl:value-of select="$Title"/>
</title>
</xsl:template>


regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top