473,626 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with XSL to make HTML table

Hi: I'm new with this & need help creating a XSL table that looks
like the following:
---------------------------------------------------------
| | | | | |
|Title |CrossCut |Institution |START |END |
| | | | | |
| | |PI | | |
| | | | | |
|Project| | | | |
|Summary| | | | |
---------------------------------------------------------

XML :

<Programs>
<Title>DETECTIN G AND BLOCKING</Title>
<CrossCut>BAS E</CrossCut>
<PI>John Jones</PI>
<Institution>IN STITUTE</Institution>
<Project_Summar y>build an effective</Project_Summary >
<Start>2004-09-15T00:00:00</Start>
<End>2006-09-14T00:00:00</End>
</Programs>
<Programs>
<Title>NETWORKS </Title>
<CrossCut>BAS E</CrossCut>
<PI>Mary QuiteContrary</PI>
<Institution>BO STON UNIVERSITY</Institution>
<Project_Summar y>This application describes an
important</Project_Summary >
<Start>2004-08-15T00:00:00</Start>
<End>2007-08-14T00:00:00</End>
</Programs>
<Programs>
<Title>NETWORKS </Title>
<CrossCut>BAS E</CrossCut>
<PI>Harry Pit</PI>
<Institution>Un iversity</Institution>
<Project_Summar y>This application describes an
important</Project_Summary >
<Start>2004-08-15T00:00:00</Start>
<End>2007-08-14T00:00:00</End>
</Programs>
The desired effect will be to sorta group by Title (see that two
titles are same) with subsequent details spanning the row.

Thanks very much for any help I could really use it-- Ginger
Jul 20 '05 #1
6 3674
Virginia Kirkendall <vk*********@ho tmail.com> wrote:
Hi: I'm new with this & need help creating a XSL table that looks
like the following:
---------------------------------------------------------
| | | | | |
|Title |CrossCut |Institution |START |END |
| | | | | |
| | |PI | | |
| | | | | |
|Project| | | | |
|Summary| | | | |
---------------------------------------------------------

XML :

<Programs>
<Title>DETECTIN G AND BLOCKING</Title>
<CrossCut>BAS E</CrossCut>
<PI>John Jones</PI>
<Institution>IN STITUTE</Institution>
<Project_Summar y>build an effective</Project_Summary >
<Start>2004-09-15T00:00:00</Start>
<End>2006-09-14T00:00:00</End>
</Programs>
<Programs>
<Title>NETWORKS </Title>
<CrossCut>BAS E</CrossCut>
<PI>Mary QuiteContrary</PI>
<Institution>BO STON UNIVERSITY</Institution>
<Project_Summar y>This application describes an
important</Project_Summary >
<Start>2004-08-15T00:00:00</Start>
<End>2007-08-14T00:00:00</End>
</Programs>
<Programs>
<Title>NETWORKS </Title>
<CrossCut>BAS E</CrossCut>
<PI>Harry Pit</PI>
<Institution>Un iversity</Institution>
<Project_Summar y>This application describes an
important</Project_Summary >
<Start>2004-08-15T00:00:00</Start>
<End>2007-08-14T00:00:00</End>
</Programs>
The desired effect will be to sorta group by Title (see that two
titles are same) with subsequent details spanning the row.

Thanks very much for any help I could really use it-- Ginger

Get a patched Bash shell with Expat XML parser interface,
http://freshmeat.net/projects/bashdiff/
help xml
help basp

First, parsing of your XML text would go something like

start () {
if [[ ${XML_ELEMENT_S TACK[1]} == Programs ]]; then
unset Title Crosscut Pi Institution Project_Summary Start End
fi
}
data () {
case ${XML_ELEMENT_S TACK[1]} in
Title|CrossCut| PI|Institution| Project_Summary |Start|End)
strcat ${XML_ELEMENT_S TACK[1]} "$1" ;;
esac
}
end () {
if [[ ${XML_ELEMENT_S TACK[1]} == Programs ]]; then
cat <<+ EOF
Title={$Title}
CrossCut={$Cros sCut}
PI={$PI}
Institution={$I nstitution}
Project_Summary ={$Project_Summ ary}
Start={$Start}
End={$End}
EOF
fi
}
xml -s start -d data -e end "`< file.xml`"

You should get

Title={DETECTIN G AND BLOCKING}
CrossCut={BASE}
PI={John Jones}
Institution={IN STITUTE}
Project_Summary ={build an effective}
Start={2004-09-15T00:00:00}
End={2006-09-14T00:00:00}

for the first <Programs>... </Programs> section. Now, if you consider

cat <<+ EOF
...
EOF

as HTML template, with '...' replaced by your table template, then your
solution becomes self-evident. If you have HTML code in a file, then
you can use my BASP (Bash Server Pages) engine.

For that, your template would go something like

<table> ...
<td><% echo -n $Title %></td>
<td><% echo -n $CrossCut %></td>
...
</table>

and you would print it, like

basp "`< template.html`"

--
William Park <op**********@y ahoo.ca>
Open Geometry Consulting, Toronto, Canada
Jul 20 '05 #2
William Park <op**********@y ahoo.ca> wrote:
start () {
if [[ ${XML_ELEMENT_S TACK[1]} == Programs ]]; then
unset Title Crosscut Pi Institution Project_Summary Start End
Typo... should be 'CrossCut' and 'PI'.
fi
}
For that, your template would go something like

<table> ...
<td><% echo -n $Title %></td>
<td><% echo -n $CrossCut %></td>


You can use shortcut, ala ASP,
<td><%=$Title%> </td>
...

--
William Park <op**********@y ahoo.ca>
Open Geometry Consulting, Toronto, Canada
Jul 20 '05 #3
> The desired effect will be to sorta group by Title (see that two
titles are same) with subsequent details spanning the row.


Hi,

This is an XSLT solution to your problem ,or at least, what I understand
of it.

<?xml version="1.0" ?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>

<xsl:key name="title" match="Title" use="."/>
<xsl:template match="/">
<html>
<head>
</head>
<body>
<table>
<xsl:for-each
select="//Title[generate-id(.)=generate-id(key('title', .))]">
<!-- Loop through all titles (no duplicates) -->
<xsl:sort select="current ()"/>
<tr>
<th>Title</th>
<th>Crosscut</th>
<th>PI</th>
<th>Institution </th>
<th>Project_Sum mary</th>
<th>Start</th>
<th>End</th>
</tr>
<xsl:apply-templates select="//Programs[Title= current() ]"/>
</xsl:for-each>
</table>
</body></html>
</xsl:template>

<xsl:template match="Programs ">
<tr>
<td><xsl:valu e-of select="Title"/></td>
<td><xsl:valu e-of select="CrossCu t"/></td>
<td><xsl:valu e-of select="PI"/></td>
<td><xsl:valu e-of select="Institu tion"/></td>
<td><xsl:valu e-of select="Project _Summary"/></td>
<td><xsl:valu e-of select="Start"/></td>
<td><xsl:valu e-of select="End"/></td>
</tr>
</xsl:template>

</xsl:stylesheet>

regards,

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #4
Thanks so much for your reply. This is getting very close!
Unfortunately, it's not quite there. The row headers do not repeat
for each duplicate title, which is good, but the records do repeat.
I am trying to understand your code & which elements are trying to
group the records, but I am new to this & haven't quite figured it
out. Again, thanks very much for posting your code.

"Joris Gillis" <ro**@pandora.b e> wrote in message news:<op******* *******@news.pa ndora.be>...
The desired effect will be to sorta group by Title (see that two
titles are same) with subsequent details spanning the row.


Hi,

This is an XSLT solution to your problem ,or at least, what I understand
of it.

<?xml version="1.0" ?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>

<xsl:key name="title" match="Title" use="."/>
<xsl:template match="/">
<html>
<head>
</head>
<body>
<table>
<xsl:for-each
select="//Title[generate-id(.)=generate-id(key('title', .))]">
<!-- Loop through all titles (no duplicates) -->
<xsl:sort select="current ()"/>
<tr>
<th>Title</th>
<th>Crosscut</th>
<th>PI</th>
<th>Institution </th>
<th>Project_Sum mary</th>
<th>Start</th>
<th>End</th>
</tr>
<xsl:apply-templates select="//Programs[Title= current() ]"/>
</xsl:for-each>
</table>
</body></html>
</xsl:template>

<xsl:template match="Programs ">
<tr>
<td><xsl:valu e-of select="Title"/></td>
<td><xsl:valu e-of select="CrossCu t"/></td>
<td><xsl:valu e-of select="PI"/></td>
<td><xsl:valu e-of select="Institu tion"/></td>
<td><xsl:valu e-of select="Project _Summary"/></td>
<td><xsl:valu e-of select="Start"/></td>
<td><xsl:valu e-of select="End"/></td>
</tr>
</xsl:template>

</xsl:stylesheet>

regards,

Jul 20 '05 #5
Hi,

Perhaps this could get you closer to your goal:

<xsl:key name="title" match="Title" use="."/>
<xsl:template match="/">
<html>
<head>
</head>
<body>
<table>
<xsl:for-each select="//Title[generate-id(.)=generate-id(key('title', .))]">
<!-- Loop through all titles (no duplicates) -->
<!-- sort on title -->
<xsl:sort select="current ()"/>
<!-- print table headers -->
<tr>
<th>Title</th>
<th>Crosscut</th>
<th>PI</th>
<th>Institution </th>
<th>Project_Sum mary</th>
<th>Start</th>
<th>End</th>
</tr>
<!-- evaluate all 'Programs' nodes that have a 'Title' child equal to the Title of this iteration of the for-each loop -->
<xsl:apply-templates select="//Programs[Title=current()]"/>
</xsl:for-each>
</table>
</body></html>
</xsl:template>

<xsl:template match="Programs ">
<!-- print a new table row and evaluate the children of the 'Programs' node -->
<tr>
<td><xsl:appl y-templates select="Title"/></td>
<td><xsl:appl y-templates select="CrossCu t"/></td>
<td><xsl:appl y-templates select="PI"/></td>
<td><xsl:appl y-templates select="Institu tion"/></td>
<td><xsl:appl y-templates select="Project _Summary"/></td>
<td><xsl:appl y-templates select="Start"/></td>
<td><xsl:appl y-templates select="End"/></td>
</tr>
</xsl:template>

<xsl:template match="*">
<!-- select the text value of a node unless it's a duplicate of a previous text value-->
<!-- in other words, only unique text values will be returned-->
<xsl:if test="generate-id(//*[.=current()][../Title = current()/../Title ])=generate-id(.)">
<xsl:value-of select="."/>
</xsl:if>
</xsl:template>

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #6
Joris! Thank you. Thank you.

This is great & you've helped me to begin to understand. Many, many thanks,

Ginger
Jul 20 '05 #7

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

Similar topics

2
1538
by: Mark | last post by:
Hi all, This is what I'm trying to do. I'm trying to load a flash movie transparently over my existing html page (not covering the full screen, but 75% of it), so it is kind of similar to a "splash screen" in the respect it is to be an introductory screen. I already have a flash movie made (although for some reason WMODE=TRANSPARENT isn't working), but we'll get to that in a sec. I also already have all the html for the playing the...
21
2878
by: BT | last post by:
I inherited a simple page that needs to be Strict HTML and I'm not very familiar with this standard. What I'm trying to do _should be_ pretty simple so I hope someone can point me in the right direction. I'm trying to make a table with 2 columns split down the middle - simple enough. In the past, without Strict HTML, I would just specify the width of each 'cell' as 50%, but width isn't allowed in a <td> under Strict HTML. Sometimes I...
2
2054
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP (non-.Net) if I wanted to fill a list it may look something like this: -------START CODE <%
2
2310
by: Goober | last post by:
I have the following default.aspx page that works properly. However, what I want to do is to link the graphics within it (that are hard coded now in the default web page) to our corporate website, which has the same graphics rotated on a 30 day basis or so. They have a standard naming convention where I know the 3 graphics are always going to be fa_mmyy.jpg, am_mmyy.jpg, and ax_mmyy.jpg. The HTML follows:
9
4833
by: Tristán White | last post by:
Hi I am very new to PHP - actually, this is my second day at it, as I've only recently started a new job last week. We're a charity. I have a "No input file selected" problem. A Google search has shown me that this is a common problem, but I have tried to follow all the various instructions but none of them make any difference. First of all... Some background on the page it links from.....
4
8350
by: Rabel | last post by:
I am not very good at javascript I mostly am a flash developer but I am trying to apply one of our old expanding menus to work for a new site but it doesn't collapse the way I need it to right now the code I am using looks like this function openSubCategory(n, nn) { var i = 0 for(i=1;i<n+1;i++) { var sel = document.getElementById('insideSubCategory'+i); sel.style.display = 'none';
1
1794
by: atombee | last post by:
Hi- this is the project that will not end! (sure you've all been there). I had originally purchased a php/css nav bar for the client, but it was buggy as hell, so I decided to do in css, in which I am still a novice, I am afraid. You can see the sample nav bar at www.tangerine-sky.com/horizontal_nav.html (I am pasting source code below) It's very simple, has the css included in the page ... works fine on a mac, okay on firefox on a PC but...
0
5557
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
5
3685
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually for repeated html im using the external js, i mean the TOP, BOTTOM they are repeated in every page, so i include them as functions in the external js and call them. Why it doesn't work?
9
7340
by: Chris Ahmsi | last post by:
I have been tasked to create a 'simple' form in Access providing managers to input necessary changes. I have 2 command buttons on the form and a check box. Command button 1 updates my table for multiple entries, and command button 2 e-mails the table in HTML format to my team, appends the data entered to a back-up table, and deletes the entries on the current table. When the check box on my form is checked (indicating a permanent change) I...
0
8259
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...
1
8358
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8502
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
7188
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
5571
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
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
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 we have to send another system
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1504
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.