473,386 Members | 2,129 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,386 software developers and data experts.

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 1981
"Paulo Pinto" <pj***@progtools.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***@progtools.org> wrote in message
news:Be*******************@news2.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***@wolterinkwebdesign.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***@wolterinkwebdesign.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***@wolterinkwebdesign.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:template 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="document('../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
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...
0
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...
3
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 ...
2
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...
6
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 ...
3
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...
1
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...
1
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.