473,738 Members | 10,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xml to html (table)

I have a situation where I need to convert an xml file into two types
of tables in html. I have never done anything like this before, so I
have been reading up on it online. However, I am not 100 percent sure
where to begin.

Here is an example of an xml file I have:

<SquishReport version="1.2" >
<summary fatals="0" testcases="13" expected_fails= "0"
unexpected_pass es="0" warnings="0" tests="180" errors="0" fails="0"
passes="180" />
<testresult message="Start 'suite_second'" result="START"
time="2007-03-23T10:51:43" >Test 'suite_second' started</testresult>
<testresult fatals="0" expected_fails= "0" unexpected_pass es="0"
warnings="0" errors="0" message="Start 'tst_BooleanApp '"
result="START_T EST_CASE" fails="0" time="2007-03-23T10:51:43"
passes="16" >Test Case 'tst_BooleanApp ' started</testresult>
<testresult line="../shared/scripts/common.py:1218"
message="Compar ison" result="PASS" time="2007-03-23T10:51:49" >'False'
and 'False' are equal (Member Value test of Default_true at line 52)</
testresult>
<testresult line="test.py:1 40" message="Read Only Test: Object
property comparison of ':mw.mw->wf.mw->wf->app_spl.QFrame 1.mw->wf-
>app_spl->panel.mw->wf->app_spl->panel->tab:f/t.tab pages.mw->wf-
app_spl->panel->tab:f/t-
scroll:all.QVi ewportWidget1.Q Frame1.UI_Check _Box5.mw->wf->app_spl-
panel->tab:f/t->scroll:all->check_box:read _only.enabled' passed"
result="PASS" time="2007-03-23T10:51:54" >'false' and 'false' are
equal (Read Only Test)</testresult>
<testresult message="End 'tst_BooleanApp '" result="END_TES T_CASE"
time="2007-03-23T10:52:02" >End of test case 'tst_BooleanApp '</
testresult>
<testresult fatals="0" expected_fails= "0" unexpected_pass es="0"
warnings="0" errors="0" message="Start 'tst_CadNoteApp '"
result="START_T EST_CASE" fails="0" time="2007-03-23T10:52:03"
passes="6" >Test Case 'tst_CadNoteApp ' started</testresult>
<testresult line="../shared/scripts/common.py:1218"
message="Compar ison" result="PASS" time="2007-03-23T10:52:18" >'test'
and 'test' are equal (Member Value test of Name at line 73)</
testresult>
<testresult line="../shared/scripts/common.py:1218"
message="Compar ison" result="PASS" time="2007-03-23T10:52:19" >'test2'
and 'test2' are equal (Member Value test of Author at line 98)</
testresult>
<testresult message="End 'tst_CadNoteApp '" result="END_TES T_CASE"
time="2007-03-23T10:52:31" >End of test case 'tst_CadNoteApp '</
testresult>
<testresult message="End 'suite_second'" result="END"
time="2007-03-23T10:58:16" >End of test 'suite_second'</testresult>
</SquishReport>

I understand the xml file is poorly formated but this is the way test
cases are represented within this certain program. If it needs a
little more explanation: Every time a test suite is run, or a specific
test within that suite, it is represented as a testresult.

I need to make one table that will have every test suite that is run
(every START/END_TEST_CASE) with it's name, a icon of green or red
depending on if everything passed, # of tests run, # of tests passed.

I also need to make a table for each of these test suites that has
each test that resides in that suite. (every other testresult between
each START/END_TEST_CASE)

This tasks seems a little hard for my first try at this, especially
with how the tests are represented in xml. All the help is
appreciated, thanks!

Mar 23 '07 #1
1 3036
in message <11************ *********@l77g2 000hsb.googlegr oups.com>,
fo***********@g mail.com ('fo*********** @gmail.com') wrote:
I have a situation where I need to convert an xml file into two types
of tables in html. I have never done anything like this before, so I
have been reading up on it online. However, I am not 100 percent sure
where to begin.

Here is an example of an xml file I have:

<SquishReport version="1.2" >
<summary fatals="0" testcases="13" expected_fails= "0"
unexpected_pass es="0" warnings="0" tests="180" errors="0" fails="0"
passes="180" />
<testresult message="Start 'suite_second'" result="START"
time="2007-03-23T10:51:43" >Test 'suite_second' started</testresult>
<testresult fatals="0" expected_fails= "0" unexpected_pass es="0"
warnings="0" errors="0" message="Start 'tst_BooleanApp '"
result="START_T EST_CASE" fails="0" time="2007-03-23T10:51:43"
passes="16" >Test Case 'tst_BooleanApp ' started</testresult>
<testresult line="../shared/scripts/common.py:1218"
message="Compar ison" result="PASS" time="2007-03-23T10:51:49" >'False'
and 'False' are equal (Member Value test of Default_true at line 52)</
testresult>
<testresult line="test.py:1 40" message="Read Only Test: Object
property comparison of ':mw.mw->wf.mw->wf->app_spl.QFrame 1.mw->wf-
>>app_spl->panel.mw->wf->app_spl->panel->tab:f/t.tab pages.mw->wf-
app_spl->panel->tab:f/t-
scroll:all.QV iewportWidget1. QFrame1.UI_Chec k_Box5.mw->wf->app_spl-
panel->tab:f/t->scroll:all->check_box:read _only.enabled' passed"
result="PASS" time="2007-03-23T10:51:54" >'false' and 'false' are
equal (Read Only Test)</testresult>
<testresult message="End 'tst_BooleanApp '" result="END_TES T_CASE"
time="2007-03-23T10:52:02" >End of test case 'tst_BooleanApp '</
testresult>
<testresult fatals="0" expected_fails= "0" unexpected_pass es="0"
warnings="0" errors="0" message="Start 'tst_CadNoteApp '"
result="START_T EST_CASE" fails="0" time="2007-03-23T10:52:03"
passes="6" >Test Case 'tst_CadNoteApp ' started</testresult>
<testresult line="../shared/scripts/common.py:1218"
message="Compar ison" result="PASS" time="2007-03-23T10:52:18" >'test'
and 'test' are equal (Member Value test of Name at line 73)</
testresult>
<testresult line="../shared/scripts/common.py:1218"
message="Compar ison" result="PASS" time="2007-03-23T10:52:19" >'test2'
and 'test2' are equal (Member Value test of Author at line 98)</
testresult>
<testresult message="End 'tst_CadNoteApp '" result="END_TES T_CASE"
time="2007-03-23T10:52:31" >End of test case 'tst_CadNoteApp '</
testresult>
<testresult message="End 'suite_second'" result="END"
time="2007-03-23T10:58:16" >End of test 'suite_second'</testresult>
</SquishReport>

I understand the xml file is poorly formated but this is the way test
cases are represented within this certain program. If it needs a
little more explanation: Every time a test suite is run, or a specific
test within that suite, it is represented as a testresult.
OK, no XML parser can parse that data as presented. The reason is that the
angle bracket characters '<' and '>' are irreducibly magic in XML. So the
first thing you need to do is to replace the right angle bracket
characters in the above which do not delimit markup with '&gt;'. Until you
do that, you can't do anything. If the above is an example which gives all
the problem cases, then passing it through

sed 's/\([ |-]\)>/\1&gt;/g'

would solve the problem.

Having done that, you want templates something like

<xsl:template match="SquishRe port">
<html>
<head>
<title>
Froboz
</title>
</head>
<body>
<xsl:apply-templates select="summary "/>
<table>
<xsl:apply-templates select="testres ult"/>
</table>
</body>
</html>
</xsl:template>

<xsl:template match="testresu lt">
<tr>
<th><xsl:valu e-of select="@messag e"/></th>
<td><xsl:valu e-of select="@time"/></td>
<td><xsl:valu e-of select="@result "></td>
<td><xsl:appl y-templates/></td>
</tr>
</xsl:template>

Obviously, I haven't dealt with all your attributes, and I haven't dealt
with your summary - but that should give you a framework to get started.
>
I need to make one table that will have every test suite that is run
(every START/END_TEST_CASE) with it's name, a icon of green or red
depending on if everything passed, # of tests run, # of tests passed.

I also need to make a table for each of these test suites that has
each test that resides in that suite. (every other testresult between
each START/END_TEST_CASE)
Someone cleverer than me may be able to solve this for you; I can't. One
cannot in principle introduce unbalanced markup in XSL, so

<xsl:template select="testres ult[@result='END_TE ST_CASE']">
</table>
<table>
</xsl:template>

is not going to work. Essentially the thing which generates the XML in the
first place needs to generate a

<SquishReport ...>
<summary ../>
<testcase>
<testresult ...></testresult>
<testresult ...></testresult>
<testresult ...></testresult>
</testcase>
<testcase>
<testresult ...></testresult>
<testresult ...></testresult>
<testresult ...></testresult>
</testcase>
...
</SquishReport>

pattern - or, at least, that would make life MUCH easier for you.

--
si***@jasmine.o rg.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

Error 1109: There is no message for this error

Mar 24 '07 #2

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

Similar topics

0
2231
by: SteveJ | last post by:
All, Can someone help me solve the next step. First of all let me say I'm new to php. I pieced the following code together from samples I found on the net and a book I bought called PHP Cookbook. So please forgive me if this isn't the best approach - I'm open to suggestions I finally got my code to work that logs into another site and pulls the orderstatus page to my server.
10
26875
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
10
2292
by: Peter Kirk | last post by:
Hi there can someone please help me with creating dynamic content in a table? For example, see the below javascript and html - why is a new row not created in the table when I click the button? (I am using Internet Explorer 6). <html> <head> <title>TEST</title> <script language="javascript">
20
5641
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just client-side HTML, CSS, etc. What I want to do is somehow insert a *server control* into the , then set the server control's properties at runtime.
5
4081
by: Andrew | last post by:
Hi, friends, In ASP, we use obj = CreateObject("com.dll") obj.GetHTMLText(inVal, outHTMLTxt1, outHTMLTxt2) to get different HTML strings based on input values. Then, we insert them into proper location of HTML something like the following: <table>
1
16974
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot examples I found on the web. Works in IE and mozilla. http://www.imaputz.com/cssStuff/bigFourVersion.html
2
2147
by: lynx129 | last post by:
Hi there , I have php script that works fine under my server but I dont know how to put the html code inside my site. feedback.html <html dir="rtl"> <head> <title> ????? ??? </title> </head> <body>
7
3614
by: imtmub | last post by:
I have a page, Head tag Contains many Scripts and style sheet for Menu and Page. This code working fine and displaying menus and page as i wanted. Check this page for reference. http://www.marco.com.cn/web-content/marco_re10.html -------------------------------------------------------------- <head> <!-- InstanceBeginEditable name="doctitle" --> <title>Marco</title> <!-- InstanceEndEditable -->
2
3059
by: sateeshchandrasanga | last post by:
Hi All, My HTML code is working fine in Firefox.But its not displaying any thing in IE.Can you help me in this problem.And in Google crown its displaying but not properly. contactus.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
10
6975
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
8969
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
9476
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...
1
9263
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
9208
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...
1
6751
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
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
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
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.