conditionalize enclosing tags with xslt

D

danmc91

I have a set of xml files and a .xsl file which I use to produce html
output. However, I want 2 versions of each html file. In one version,
I want the whole thing. In the second version I only want whats
inclosed by the <body> tag.

So, I tried defining a parameter which I can override on the command
line and doing something like:

<xsl:if test="$header = 'yes'">
<html>
<head>
<!--head stuff here-->
</head>
<body>
</xsl:if>

and a similar thing at the end for the closing body and html tags.
However xsltproc does not like this since I've wrapped the opening tags
and closing tags in their own if's.

Any suggestions on how to deal with this without resorting to some
awk/sed hacks?

Thanks
-Dan
 
?

=?ISO-8859-1?Q?Joachim_Wei=DF?=

danmc91 said:
<xsl:if test="$header = 'yes'">
<html>
<head>
<!--head stuff here-->
</head>
<body>
</xsl:if>

Any suggestions on how to deal with this without resorting to some
awk/sed hacks?

no hacks needed. Easiest solution is:
<xsl:choose>
<xsl:when test="$header = 'yes'">
<html>
<head>
<!--head stuff here-->
</head>
<body>
<!--body stuff here which is hopefully only a apply-templates or a
call-template -->
</body>
</html>
</xsl:when>
<xsl:eek:therwise>
<!--body stuff here which is hopefully only a apply-templates or a
call-template -->
</xsl:eek:therwise>
</xsl:choose>


HIH Jo
 
D

danmc91

Thanks! That did the trick. I'm starting to feel like if I ever get
more proficient with this stuff (DTD/XML/XSLT) it will be rather
useful!

-Dan
 

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

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top