473,506 Members | 17,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSL ... two templates ?


I have some XML/XSL web pages which display data grids (stored in XML
and formatted by the XSL file). This works fine.

However, I would like to retrieve an item of text from the grid (one
particular column which will later be removed from the display) and show
this as a main title for the page (i.e. the title will vary depending on
the grid that is opened).

The result should look like this:

Region: London

Month Sales Sales Person
Jan 4345 John
Jan 8494 Sue
Jan 7849 Peter

The grid works fine but I am having trouble plucking the title (in this
case 'London') out of the XML file for prior display.

I believe that I need to declare two templates (i.e. one for the title
and one for the grid) but am really not sure how to do this.

Does anyone have an idea? Or maybe a suggestion for an alternative
technique?

Any tips or recommendations of tutorials would be a great help.

Many thanks,
Alan Searle

PS: Remove the xxx in the e-mail to send me a message
Jan 4 '06 #1
3 1104


Alan Searle wrote:
However, I would like to retrieve an item of text from the grid (one
particular column which will later be removed from the display) and show
this as a main title for the page (i.e. the title will vary depending on
the grid that is opened).


What you need to do depends on the input XML, in terms of XSLT all you
need to do is put a literal result title element with e.g.
<title><xsl:value-of select="/element/child1/child2/child" /></title>
at the proper place where the title element belongs in HTML. That XPath
expression as the select attribute value of course needs to be written
according to which element you want to select in your XML but as you
haven't bothered to share your XML that is all we can suggest.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 4 '06 #2
Hi Martin,

Thanks for your tip ...
However, I would like to retrieve an item of text from the grid (one
particular column which will later be removed from the display) and
show this as a main title for the page (i.e. the title will vary
depending on the grid that is opened).
What you need to do depends on the input XML, in terms of XSLT all you
need to do is put a literal result title element with e.g.
<title><xsl:value-of select="/element/child1/child2/child" /></title>
at the proper place where the title element belongs in HTML.


This sounds like exactly what I need but I gave it a try and couldn't
get it to display. That's a shame.
That XPath
expression as the select attribute value of course needs to be written
according to which element you want to select in your XML but as you
haven't bothered to share your XML that is all we can suggest.


Sorry about not sending the XML. Below are excerpts from the XML and
XSL files (I want to display the 'LangFrom' field in the title) ...

Excerpt from XML ...
--------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="OpenJobs.xsl" type="text/xsl"?>
<dataroot>
<job>
<job_id>8029</job_id>
<Status>A</Status>
<job_Title>Report 2005</job_Title>
<Action_pers>Hansen, M</Action_pers>
<LangFrom>EN</LangFrom>
<LangInto>DA</LangInto>
<job_Pages>0.5</job_Pages>
</job>
<job>
<job_id>7948</job_id>
<Status>C</Status>
<job_Title>Update of OrgaChart</job_Title>
<Action_pers>Hald, B</Action_pers>
<LangFrom>EN</LangFrom>
<LangInto>DA</LangInto>
<job_Pages>1</job_Pages>
</job>
</dataroot>

Excerpt from the XSL ...
------------------------
....
<xsl:template match="dataroot">
<html>
<head>

<script language="JavaScript" type="text/javascript">
... some javascript here
</script>

</head>
<body>
<h1>Language: <xsl:value-of select="/job/LangFrom" /></h1>

<table width="95%" border="1">
<tr bgcolor="#dddddd" VALIGN="TOP">
<td class="head" onclick="sort('job_id');">Job</td>
<td class="head" onclick="sort('Status');">On Hold</td>

Code goes on to display the grid in this table ...
-------------------------

Maybe you have an idea why this isn't working?

And I was wondering if I need to include an 'apply-template' statement
too? e.g. <xsl:apply-templates select="job">

Thanks very much for your help.

Regards,
Alan Searle
Jan 4 '06 #3
Hi Martin,

I played around with your idea ...
What you need to do depends on the input XML, in terms of XSLT all you
need to do is put a literal result title element with e.g.
<title><xsl:value-of select="/element/child1/child2/child" /></title>
at the proper place where the title element belongs in HTML.


.... adapted it a little ...

<xsl:apply-templates select="/dataroot/job[1]/LangFrom" />

.... and got it working. I'm very pleased.

Indeed, at first it displayed the header multiple times but then I added
'job[1]' to limit it to the first record and it was fine.

Thanks for your tips: You put me on the right track!

Regards,
Alan
Jan 4 '06 #4

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

Similar topics

1
2549
by: Vince C. | last post by:
Hi all, I've created XML documents that are described with a schema. I'm using those documents to create web pages. All my web pages contain a fixed header and a variable document part. The...
5
2516
by: Tom Alsberg | last post by:
Hi there... I'm recently trying to get a bit acquainted with XML Schemas and XSL. Now, I have a few questions about XSL stylesheets and templates: * Is there a way to "enter" a child element...
22
2145
by: E. Robert Tisdale | last post by:
According to the C++ FAQ Lite: http://www.parashift.com/ What is "genericity"? Yet another way to say, "class templates." Not to be confused with "generality" (which just means avoiding...
12
1947
by: Fabio De Francesco | last post by:
Hello. I can't understand why I can't compile the following simple code, where I think I have applied all the needed rules for templates that are declared and defined in different files (*.h and...
16
16201
by: WittyGuy | last post by:
Hi, What is the major difference between function overloading and function templates? Thanks! http://www.gotw.ca/resources/clcm.htm for info about ]
2
1614
by: jimbo_vr5 | last post by:
Hey I think i've figured out the idea behind apply-templates. But going through the tutorial on <http://www.w3schools.com/xsl/xsl_apply_templates.asp> theres simply just something that i dont...
25
3289
by: Ted | last post by:
I'm putting the posts that follow here (hopefully they will follow here!) because they were rejected in comp.lang.c++.moderated. It behooves anyone reading them to first read the the thread of the...
28
2598
by: NewToCPP | last post by:
Hi, I am just trying to find out if there is any strong reason for not using Templates. When we use Templates it is going to replicate the code for different data types, thus increasing the...
104
4449
by: JohnQ | last post by:
Well apparently not since one can step thru template code with a debugger. But if I was willing to make the concession on debugging, templates would be strictly a precompiler thing? I have a...
7
1694
by: Chris | last post by:
Hi All, This is a weird one but I am hoping someone can help or has some pointers, a recipe how to do the following: I have to move some code from c++ to objective-c and to do this I must...
0
7105
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
7308
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
7371
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...
1
5037
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...
0
4702
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...
0
3188
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...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.