Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-11

[patch] - fpcUnit XSLT

17 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Attached is a patch for the fpcUnit's example XSLT files.

Changes:
* Grouping by Test Suites is now supported in the generated HTML
* Cleaned up the fpcunit.css file
* Added a navi.js file, which is the JavaScript required for the grouping. (Depending on others, this could be moved into the fpcunit.xsl file if preferred).

Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1

Reply by email

Vincent Snijders
to Graeme Geldenhuys
Graeme Geldenhuys wrote 10 lines
Hi, Attached is a patch for the fpcUnit's example XSLT files. Changes: * Grouping by Test Suites is now supported in the generated HTML * Cleaned up the fpcunit.css file * Added a navi.js file, which is the JavaScript required for the grouping. (Depending on others, this could be moved into the fpcunit.xsl file if preferred).

I prefer having as little files as possible, so if you can put it into fpcunit.xsl, that would be nice.

Vincent

Reply by email

Graeme Geldenhuys
to Vincent Snijders
Vincent Snijders wrote 6 lines
> * Added a navi.js file, which is the JavaScript required for the > grouping. (Depending on others, this could be moved into the > fpcunit.xsl file if preferred). I prefer having as little files as possible, so if you can put it into fpcunit.xsl, that would be nice.

OK, will do.

Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1

Reply by email

Kris Leech
to Graeme Geldenhuys: Attached is a patch for the fpcUnit's example XSLT files. Changes: * Grouping by Test…
Graeme Geldenhuys wrote 10 lines
Hi, Attached is a patch for the fpcUnit's example XSLT files. Changes: * Grouping by Test Suites is now supported in the generated HTML * Cleaned up the fpcunit.css file * Added a navi.js file, which is the JavaScript required for the grouping. (Depending on others, this could be moved into the fpcunit.xsl file if preferred).

Is this a class for actually doing XSLT transforms on XML? If so what unit / documenation can I find this in?

Show quoted text 273 lines
------------------------------------------------------------------------ Index: fcl/fpcunit/example_xsl/fpcunit.css =================================================================== --- fcl/fpcunit/example_xsl/fpcunit.css (revision 5431) +++ fcl/fpcunit/example_xsl/fpcunit.css (working copy) @@ -4,19 +4,23 @@ font-size: x-small; background: #FFFFFF; } + a { text-decoration: none; background-color: Transparent } + a:link { color: #0033ff; } + a:visited { color: #003399; } + a:active, a:hover { color:#69c; @@ -26,21 +30,22 @@ { padding: 4px 4px 4px 6px; font-size: large; - border: 1px solid black; - font-weight: bold; - color: white; - background-color: #006699; + border: 1px solid black; + font-weight: bold; + color: white; + background-color: #006699; } + h3 { padding: 4px 4px 4px 6px; border: 1px solid #003399; color: #FFFFFF; -/* #003399; */ background-color: #0099CC; font-weight: normal; font-size: medium; } + table { padding:0px; @@ -48,59 +53,90 @@ margin-left: -2px; margin-right: -2px; } + th, td { padding: 2px 4px 2px 4px; vertical-align: top; font-size: x-small; } + address { font-family: verdana, arial, helvetica, Sans-Serif; font-size: 8pt; - font-style: normal; - text-align: right; + font-style: normal; + text-align: right; } .title { background-color: #bbb; -/* #bbb; #D8D8D8 #D3E4FF */ color: white; } + .resultmessage { background-color: #D3E4FF; } + .success { background-color: lightgreen; color: black; } + .failure { background-color: #FF00FF; color: black; } + .notrun { background-color: yellow; color: black; } + .error { background-color: red; color: black; font-size: 9pt; } + .right { font-size: 8pt; text-align: right; } + .backToTop { text-align: right; } +.testsuitelabel +{ + background-color: cadetblue; + color: black; + cursor:pointer; cursor:hand; /* cross browser hack */ + padding-top: 3px; + border: 1px solid #F5F5F5; +} +.testsuiteshowall +{ + display:inline; + cursor:pointer; cursor:hand; /* cross browser hack */ +} + +.testsuitehideall +{ + display:inline; + cursor:pointer; cursor:hand; /* cross browser hack */ +} + +div.testcontent { + margin-left: 8px; +} Index: fcl/fpcunit/example_xsl/navi.js =================================================================== --- fcl/fpcunit/example_xsl/navi.js (revision 0) +++ fcl/fpcunit/example_xsl/navi.js (revision 0) @@ -0,0 +1,50 @@ + +window.onload = function () { + var x = document.getElementsByTagName('div'); + for (var i=0;i<x.length;i++) + { + if (x[i].className == 'testsuitelabel') + x[i].onclick = clickSuite; + if (x[i].className == 'testsuiteshowall') + x[i].onclick = openSuites; + if (x[i].className == 'testsuitehideall') + x[i].onclick = closeSuites; + } + + closeSuites(); +} + +function closeSuites() +{ + var x = document.getElementsByTagName('div'); + for (var i=0;i<x.length;i++) + { + if (x[i].className == 'testcontent') + x[i].style.display = 'none'; + } +} + +function openSuites() +{ + var x = document.getElementsByTagName('div'); + for (var i=0;i<x.length;i++) + { + if (x[i].className == 'testcontent') + x[i].style.display = 'block'; + } +} + +function clickSuite(e) +{ + if (!e) var e = window.event; + if (e.target) var tg = e.target; + else if (e.srcElement) var tg = e.srcElement; + while (tg.nodeName != 'DIV') // Safari GRRRRRRRRRR + tg = tg.parentNode; + var nextSib = tg.nextSibling; + while (nextSib.nodeType != 1) + nextSib = nextSib.nextSibling; + var nextSibStatus = (nextSib.style.display == 'none') ? 'block' : 'none'; + nextSib.style.display = nextSibStatus; +} + Property changes on: fcl/fpcunit/example_xsl/navi.js ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Index: fcl/fpcunit/example_xsl/fpcunit.xsl =================================================================== --- fcl/fpcunit/example_xsl/fpcunit.xsl (revision 5431) +++ fcl/fpcunit/example_xsl/fpcunit.xsl (working copy) @@ -9,6 +9,7 @@ <style type="text/css" title="fpcUnit" media="screen"> @import "fpcunit.css"; </style> + <script src="navi.js"></script> </head> <body> @@ -101,18 +102,24 @@ <!-- Test Listing Table --> <table border="0" rules="none" width="100%"> <tr align="left" class="title"> - <th width="89%" align="left">Name</th> - <th width="11%" align="left">Elapsed Time<br/>(hh:mm:ss.zzz)</th> + <td align="left">Name<br/><div class="testsuiteshowall">[show all]</div><div class="testsuitehideall">[hide all]</div></td> + <td width="150" align="right">Elapsed Time<br/>(hh:mm:ss.zzz)</td> </tr> - <xsl:for-each select="TestListing/TestSuite/Test"> - <xsl:variable name="testName" select="@Name"/> - <xsl:variable name="elapsedTime" select="ElapsedTime"/> - <tr class="success"> - <td><xsl:value-of select="$testName"/></td> - <td><xsl:value-of select="ElapsedTime"/></td> - </tr> - </xsl:for-each> </table> + <xsl:for-each select="TestListing/TestSuite"> + <div class="testsuitelabel"><xsl:value-of select="@Name"/></div> + <div class="testcontent"> + <table border="0" cellspacing="1" width="100%"> + <xsl:for-each select="./Test"> + <tr class="success"> + <td><xsl:value-of select="@Name"/></td> + <td width="150" align="right"><xsl:value-of select="ElapsedTime"/></td> + </tr> + </xsl:for-each> <!-- Test --> + </table> + </div> + </xsl:for-each> <!-- TestSuite --> + </div> <!-- testlisting --> </xsl:template> ------------------------------------------------------------------------ _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Graeme Geldenhuys
to Kris Leech
Kris Leech wrote
Is this a class for actually doing XSLT transforms on XML? If so what unit / documenation can I find this in?

No. The XML generated by fpcUnit can include a stylesheet - the fpcunit.xsl is this stylesheet. The fpcunit.xsl is used to generated HTML output, when the XML file is viewed with a Web Browser.

I also use the 'xsltproc' (a front end script for the libxslt library, available for Linux), to generate the output from the command line (no web browser needed).

Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1

Reply by email

ik
to Graeme Geldenhuys
Graeme Geldenhuys wrote 11 lines
On 11/20/06, Kris Leech wrote: > Is this a class for actually doing XSLT transforms on XML? > If so what unit / documenation can I find this in? No. The XML generated by fpcUnit can include a stylesheet - the fpcunit.xsl is this stylesheet. The fpcunit.xsl is used to generated HTML output, when the XML file is viewed with a Web Browser. I also use the 'xsltproc' (a front end script for the libxslt library, available for Linux), to generate the output from the command line (no web browser needed).

What's wrong with the XML standard of FO ? It allows you to generate almost any kind of document (including HTML and PDF) from pure xml data and xslt as template (together with FO template). The benefits are that the CSS styles are properties, so the style itself (when needed) is part of the template rather a whole new section for specific type of document.

Or am I missing something here ?

Show quoted text 8 lines
-- Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1

Ido

Reply by email

Graeme Geldenhuys
to Vincent Snijders: I prefer having as little files as possible, so if you can put it into fpcunit.xsl, that…

Hi,

Attached is a new patch for the XSTL example in fpcUnit. This time the JavaScript in inside the fpcunit.xsl file and not as a separate file. I actually like this more as well.

Regards,
- Graeme -

Vincent Snijders wrote 20 lines
Graeme Geldenhuys schreef: > Hi, > > Attached is a patch for the fpcUnit's example XSLT files. > > Changes: > * Grouping by Test Suites is now supported in the generated HTML > * Cleaned up the fpcunit.css file > * Added a navi.js file, which is the JavaScript required for the > grouping. (Depending on others, this could be moved into the > fpcunit.xsl file if preferred). I prefer having as little files as possible, so if you can put it into fpcunit.xsl, that would be nice. Vincent _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel
Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1

Reply by email

Graeme Geldenhuys
to ik: What's wrong with the XML standard of FO ? It allows you to generate almost any kind of…
ik wrote 8 lines
What's wrong with the XML standard of FO ? It allows you to generate almost any kind of document (including HTML and PDF) from pure xml data and xslt as template (together with FO template). The benefits are that the CSS styles are properties, so the style itself (when needed) is part of the template rather a whole new section for specific type of document. Or am I missing something here ?

:-) Sorry, I'm lost. What is FO?

Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1

Reply by email

ik
to Graeme Geldenhuys
Graeme Geldenhuys wrote 11 lines
On 11/21/06, ik wrote: > What's wrong with the XML standard of FO ? It allows you to generate > almost any kind of document (including HTML and PDF) from pure xml > data and xslt as template (together with FO template). The benefits > are that the CSS styles are properties, so the style itself (when > needed) is part of the template rather a whole new section for > specific type of document. > > Or am I missing something here ? :-) Sorry, I'm lost. What is FO?

It stand for XSL Formatting Objects (XSL-FO is the full name). It was created in order to allow the use of XML and the generating of universal documents. A very know FOSS thingy that uses it, is docbook.

Here is the basic (bad documented last time I checked) standard: http://www.w3.org/Style/XSL/ . There are several tools that does a good job. One of them host under Apache's foundation called fop. But like 90% of the projects hosted at Apache, it is written in Java (the real down side).

Show quoted text 8 lines
-- Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1

Ido

Reply by email

Graeme Geldenhuys
to ik
ik wrote 6 lines
What's wrong with the XML standard of FO ? It allows you to generate almost any kind of document (including HTML and PDF) from pure xml data and xslt as template (together with FO template). The benefits are that the CSS styles are properties, so the style itself (when needed) is part of the template rather a whole new section for specific type of document.

Ok, well to answer you question. I didn't know of XSL-FO. :-) I'm a fairly newbie when it comes to XSLT. I just knew what it could do, and needed to generate a HTML fpcUnit results page for the tiOPF project's daily builds and a summary email. I Google'd XSLT and found a few tutorials. fpcunit.xsl is the result of that. :-) The xsl file for the summary email is not included in fpcUnit - it's to specific to tiOPF.

As soon as I have some time, I'll read up on the XSL-FO to see if it can improve what I have done so far. If you can spot something obvious, please let me know.

Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1

Reply by email

ik
to Graeme Geldenhuys
Graeme Geldenhuys wrote 19 lines
On 11/21/06, ik wrote: > What's wrong with the XML standard of FO ? It allows you to generate > almost any kind of document (including HTML and PDF) from pure xml > data and xslt as template (together with FO template). The benefits > are that the CSS styles are properties, so the style itself (when > needed) is part of the template rather a whole new section for > specific type of document. Ok, well to answer you question. I didn't know of XSL-FO. :-) I'm a fairly newbie when it comes to XSLT. I just knew what it could do, and needed to generate a HTML fpcUnit results page for the tiOPF project's daily builds and a summary email. I Google'd XSLT and found a few tutorials. fpcunit.xsl is the result of that. :-) The xsl file for the summary email is not included in fpcUnit - it's to specific to tiOPF. As soon as I have some time, I'll read up on the XSL-FO to see if it can improve what I have done so far. If you can spot something obvious, please let me know.

Few things :)
1. When ever it is written (for example) that for border you need: border-inner-top, border-inner-left etc... you can do the same with one command (just like css), although most documents about FO that I found does not write anything about it.

2. Make sure that the DTD that you are using support the feature you wish to use, otherwise the result will not be what you are expecting.

3. You will find your writing a bigger text file then "regular" HTML. But it gives you the power to create many other types of document, from simple text file, to pdf and RTF documents (and more, depends on the engine you are using).
Please also write comments inside to know where something begins and end. It will help you more when the file is all grown and it is almost impossible to find what effects what.

4. Adobe acrobat is really buggy, so if you use PDF, please use more then one type of pdf viewer (stand alone that is) to see result of PDF files .:)

5. XSLT 1 is really bad, and if you can, work with XSLT 2 :)

That's 5 tips for start :)

Show quoted text 7 lines
-- Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1

Ido

Reply by email

Kris Leech
to Graeme Geldenhuys: No. The XML generated by fpcUnit can include a stylesheet - the fpcunit.xsl is this…
Graeme Geldenhuys wrote 15 lines
On 11/20/06, Kris Leech wrote: > Is this a class for actually doing XSLT transforms on XML? > If so what unit / documenation can I find this in? No. The XML generated by fpcUnit can include a stylesheet - the fpcunit.xsl is this stylesheet. The fpcunit.xsl is used to generated HTML output, when the XML file is viewed with a Web Browser. I also use the 'xsltproc' (a front end script for the libxslt library, available for Linux), to generate the output from the command line (no web browser needed).

Thanks for the reply, I'm guessing we do not have a unit for FPC that can do XSLT?

Reply by email

Michael Van Canneyt
to Kris Leech
Kris Leech wrote 19 lines
Graeme Geldenhuys wrote: > On 11/20/06, Kris Leech wrote: > > > Is this a class for actually doing XSLT transforms on XML? > > If so what unit / documenation can I find this in? > > > No. The XML generated by fpcUnit can include a stylesheet - the > fpcunit.xsl is this stylesheet. The fpcunit.xsl is used to generated > HTML output, when the XML file is viewed with a Web Browser. > > I also use the 'xsltproc' (a front end script for the libxslt library, > available for Linux), to generate the output from the command line (no > web browser needed). > > Thanks for the reply, I'm guessing we do not have a unit for FPC that can do XSLT?

You are guessing correct. Any contributions in this area are hugely welcome.

An XML mapper tool such as in delphi, written on top of an XSLT unit, would also be welcome ;-)

Michael.

Reply by email

Vincent Snijders
to Graeme Geldenhuys: Attached is a patch for the fpcUnit's example XSLT files. Changes: * Grouping by Test…
Graeme Geldenhuys wrote 10 lines
Hi, Attached is a patch for the fpcUnit's example XSLT files. Changes: * Grouping by Test Suites is now supported in the generated HTML * Cleaned up the fpcunit.css file * Added a navi.js file, which is the JavaScript required for the grouping. (Depending on others, this could be moved into the fpcunit.xsl file if preferred).

I am using fpcunit to check if all the snapshots are up to date: http://www.hu.freepascal.org/lazarus/testresults/monitor.xml

I see a couple of improvements:
* Add Tests, Failures, Errors, Elapsed time for testsuites too (needs a change in the xmlreporter).
* Color code the test suite line (green, ok, red failures).
* Allow test suites in other testsuites. As I wrote the tests the "Snapshot on scenergy" test suites contains most of the following test suites. So they should be hidden in it, and if I click on the scenergy snapshot, they should become visible, just like the individual test do.
* Show the failure or error message as extra information of the test, so clicking on the test would show it.

What do you think of these improvements? Which ones are you willing to implement? If you don't do them all (in time), I will do the remaining ones.

Vincent

Reply by email

Graeme Geldenhuys
to Vincent Snijders: I am using fpcunit to check if all the snapshots are up to date:…
Vincent Snijders wrote
I see a couple of improvements:

There is always place for improvement. :-)
The last patch was just the beginning and to get some basics for the grouping working.

* Add Tests, Failures, Errors, Elapsed time for testsuites too (needs a change in the xmlreporter).

It was on my to do list, but didn't get time for it yet. I was only going to add the totol test count and total elapsed time for a testsuit. What is the Failures and Errors, a count of howmany occured in the testsuit?

* Color code the test suite line (green, ok, red failures).

Thought about that as well.

* Allow test suites in other testsuites. As I wrote the tests the "Snapshot on scenergy" test suites contains most of the following test suites. So they should be hidden in it, and if I click on the scenergy snapshot, they should become visible, just like the individual test do.

Dean sent me a patch the other day that allows for nested tests (more that the current two levels). Obviously the xslt file doesn't work with such tests yet. I haven't looked at the patch yet, to see what needs changing.

* Show the failure or error message as extra information of the test, so clicking on the test would show it.

Got this on my todo list as well. I was going to jump to the actual error or failure lower down in the page. Did you have another idea?

What do you think of these improvements? Which ones are you willing to implement? If you don't do them all (in time), I will do the remaining ones.

I'll start with the first two.

Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1

Reply by email