473,412 Members | 3,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

conditionalize enclosing tags with xslt


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

Oct 20 '05 #1
2 1129
danmc91 schrieb:

<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:otherwise>
<!--body stuff here which is hopefully only a apply-templates or a
call-template -->
</xsl:otherwise>
</xsl:choose>
HIH Jo Thanks
-Dan

Oct 20 '05 #2
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

Oct 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Francis Hwang | last post by:
Hi, Maybe this is a newbie question, but: Is there a way to output an element's contents -- including contained nodes and free-form text -- without the containing tags? I can imagine that...
2
by: Joe | last post by:
How would you preserve tags from an XML element in XSLT output.. Example: XML document has an ELEMENT "SECTION" allowing contained HTML This element might have an element such as <A...
4
by: Luke Dalessandro | last post by:
I have some XML data that has mixed content XML tags that embed XHTML tags, for instance: <note>Somebody wrote this note in XHTML and wanto to <a href="link.html" target="_new">link</a> to a...
8
by: Kathleen Dollard | last post by:
Hi, Oleg's answer about attribute value templates led me to look back at a different problem, and wonder if someone else had solved it. I want to output an ASP.NET page. Thus I need to output...
2
by: Richard L Rosenheim | last post by:
Is it possible to include addition tags in a XSLT file, that the XSLT processor will, for all practical purposes, ignore? What I'm looking to do is to include a section to contain information...
5
by: Thierry | last post by:
Let's say I have the following tags in an xml: <World> <Country>Canada</Country> <Hemisphere>North</Hemisphere> <Weather climate="cold" forecast="snow"> <CommandAction>$(HOME)\calculate.py...
4
by: dwergkees | last post by:
Hi, Got a litte problem here. I'm trying to create a XSLT file that will do a transformation from WordML format (MS Word XML format, see...
7
by: jmp | last post by:
(I hope this isn't considered too far off-topic.) I work as a developer on a browser product found on handheld devices, and I'm trying to specify behavior for the browser to make it "as...
2
by: Andy | last post by:
Hi, I have an ASP.NET webpage that contains an ASP.NET XML control. This control accepts an XSLT stylesheet and XML document which it then uses to render HTML code where the XML control is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.