473,799 Members | 2,997 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making XSLT stylesheets more modular

Hi,

I have already several XSLT stylesheets that
make use of <xslt:include > "command". Now
I wanted to make them a bit more modular but
I'm stuck.

I want to take out the generated HTML code
for the footer and header to some files that could
be included by the stylesheets.

So far I wasn't able to use any XSLT inclusion mechanism
that works.

Any ideas?

Thanks in advance,
Paulo Pinto
Jul 20 '05 #1
8 2014
"Paulo Pinto" <pj***@progtool s.org> writes:
Hi,

I have already several XSLT stylesheets that
make use of <xslt:include > "command". Now
I wanted to make them a bit more modular but
I'm stuck.

I want to take out the generated HTML code
for the footer and header to some files that could
be included by the stylesheets.

So far I wasn't able to use any XSLT inclusion mechanism
that works.

Any ideas?

Thanks in advance,
Paulo Pinto


what did you try?

sounds like you want to make a stylesheet that just has a named template
that generates a header then xsl:include that into your main stylestss
and use call-template at teh point that you want the header to apear.

David
Jul 20 '05 #2
Paulo Pinto wrote:
I want to take out the generated HTML code
for the footer and header to some files that could
be included by the stylesheets.

Try to wrap the html into simple xsl and then include.

--
the code is my strength
SirMike
Jul 20 '05 #3
Paulo Pinto wrote:
Hi,

I have already several XSLT stylesheets that
make use of <xslt:include > "command". Now
I wanted to make them a bit more modular but
I'm stuck.

I want to take out the generated HTML code
for the footer and header to some files that could
be included by the stylesheets.

So far I wasn't able to use any XSLT inclusion mechanism
that works.

Any ideas?

Thanks in advance,
Paulo Pinto


i think i know what you mean,
you cannot have the footer and header html in seperate files because the xml must remain a tree

<xsl:template name="layout">
<a>
<b>
<xsl:call-template name="body"/>
</b>
</a>
</xsl:template>

cannot be separated in:

<xsl:template name="layout">
<xsl:call-template name="header"/>>
<xsl:call-template name="body"/>
<xsl:call-template name="footer"/>
</xsl:template>

<xsl:template name="header">
<a>
<b>
</xsl:template>

<xsl:template name="footer">
</b>
</a>
</xsl:template>
Jul 20 '05 #4
Thanks for the info.

I will try to play around today at home
and probably come up with a more concret
example.

--
Paulo

"Paulo Pinto" <pj***@progtool s.org> wrote in message
news:Be******** ***********@new s2.nokia.com...
Hi,

I have already several XSLT stylesheets that
make use of <xslt:include > "command". Now
I wanted to make them a bit more modular but
I'm stuck.

I want to take out the generated HTML code
for the footer and header to some files that could
be included by the stylesheets.

So far I wasn't able to use any XSLT inclusion mechanism
that works.

Any ideas?

Thanks in advance,
Paulo Pinto

Jul 20 '05 #5
On Tue, 15 Feb 2005 15:42:37 +0100, Tjerk Wolterink
<tj***@wolterin kwebdesign.com> wrote:
i think i know what you mean,
This explanation sounds likely.
you cannot have the footer and header html in seperate files because the xml must remain a tree


You can still have the "header" and "footer" generated by named
templates, you just need to avoid the <html> <head> and <body>
elements. This isn't a big restriction, because they're generally
pretty static and can just be inserted into the top level template.

Jul 20 '05 #6
Andy Dingley wrote:
On Tue, 15 Feb 2005 15:42:37 +0100, Tjerk Wolterink
<tj***@wolterin kwebdesign.com> wrote:

i think i know what you mean,

This explanation sounds likely.


i think you mean unlikely?!?!?!

you cannot have the footer and header html in seperate files because the xml must remain a tree

You can still have the "header" and "footer" generated by named
templates, you just need to avoid the <html> <head> and <body>
elements. This isn't a big restriction, because they're generally
pretty static and can just be inserted into the top level template.

it can be done, but often the conten of the page is between a tag. That tag is openend in the header
and closed in the footer. So .. yes it is possible, but it is restrictive
Jul 20 '05 #7
On Tue, 15 Feb 2005 19:35:43 +0100, Tjerk Wolterink
<tj***@wolterin kwebdesign.com> wrote:
it can be done, but often the conten of the page is between a tag. That tag is openend in the header
and closed in the footer.


If there's a single element spanning that far, then that's not a
footer, it's the body of the page.

Many of my pages have a structure like this :

<html>
[...]
<body>

<div class="header" >
[...]
</div>

<div class="nav-stuff" >
[...]
</div>

<div class="body-text" >
<div class="stuff" >
[...]
</div>

<div class="other-stuff" >
[...]
</div>
</div>

<div class="footer" >
[...]
</div>

</body></html>

Now generating the element <div class="footer" > is a valid thing for
an XSLT templte to be doing, but trying this:

<xslt:templat e name="output-footer" >
</div>
<div class="footer" >
[...]
</div>
</xslt:template>

is not only poorly-formed, but it's semantically inappropriate too.
Close that body text from the same scope in which you opened it,
whether you're writing XSLT or any other page-generation language.
Jul 20 '05 #8
OK, here goes a more detailed example.

I already have the following working situation
in my web site.

news.xml -> news.xsl -> news.html
| loads
v
toc.xml and toc.xsl
So toc.xsl is loaded with <xsl:include> and latter
on in the news.xsl file I do a

<xsl:apply-templates select="documen t('../toc.xml')/toc"/>

in the place where I want the menu to appear.

toc.xml is a xml file with the description of the web site
navigation menus.

All top level xsl files for the site follow this scheme.
Meaning that they all load toc.(xml,xsl) in order to
avoid having code related with the site navigation.

Now I would like to make those files evern lighter by
making a similar use case for the generation of the header
and footer of each page.

But now I just have the XHTML code that I want to insert
into a given place.

Hope that this explains better what I'm trying to achive.

--
Paulo
Jul 20 '05 #9

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

Similar topics

5
1822
by: john | last post by:
Hi I am devlopeing a data centric intranetsite with data in mysql database I would like your opinion on this architecture Data will be fetched from database by python & converted into xml The XSLT will be stored on the client cache.So only the xml is transferred to client & the xslt transforms it into xhtml & displays it. Will this improve performance or have i gone nuts??
0
2038
by: Federico | last post by:
Hi all, I don't know if this topic is perhaps a little bit off-topic, anyway I have a strange problem in transforming an XML file in an HTML file using XSLT form a Java program written with NetBeans. I utilize the javax.xml.transform class and in the computer where I wrote the program all function perfectly, calling the input XML file, the XSLT stylesheets and setting where to write the output HTML.
3
2195
by: Andy Dingley | last post by:
I've just started on a new project and inherited a huge pile of XSLT (and I use the term "pile" advisedly !) It runs at glacial speed, and I need to fix this this. Platform is MSXML 4 / ASP Any advice on benchmarking tools / techniques ? I have no budget for tool-building, so if there's anything already out there, that would be good to know.
2
7972
by: Claudio Jolowicz | last post by:
How can XSLT stylesheets be used to edit, remove and add nodes specified by their position in the document tree? The XML document stores development tasks in a hierarchical way, i.e. tasks can have subtasks, subsubtasks, etc. It has the following form: <todo> <note>Task 1</note> <note> Task 2
6
2878
by: David Walker | last post by:
Hi, I have an XML file created by a third party in which an element with a simple content model has a text value consisting of 2 parts separated by a colon, like this <link>machine:port</link> Is XSLT capable of parsing the value of a <link> element, to separately extract the portions before and after the colon?
3
1632
by: Darren Davison | last post by:
Hi, I have a documentation tool based on Java and XSLT that I want to add i18n capability to. There are around 8 stylesheets that process a Source generated by the Java code and some of the static labels across the stylesheets are the same. Ideally I'd like to import a set of variables into each template, and preferably based on an XSLT parameter (the locale) but this obviously doesn't work:
1
2420
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT stylesheets, that generates .NET assemblies) 2. Performance improvements in the XslCompiledTransform
1
1821
by: aplonis | last post by:
I have an XML (Atom) doc at this URL... Atom ...which displays as HTML using any one of three XSLT stylesheets, the principal one being at this URL... XSLT ...with two daughter-XSLT's, both very short, and employing
2
2662
by: TAL651 | last post by:
Hello, I'd like to use XML + XSLT to create a sortable table. The XML stores the data, and two different XSL stylesheets display the table, sorted in two different ways. What I don't understand is how to allow the user to switch between the two stylesheets (and hence two sorting options). I can provide code snippets if that would help, but I'm basically looking for the general concept here - how can you dynamically switch XSLT...
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10485
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10252
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.