[opensuse-doc] Update notification / XSLT questions
Hello, I want to mail some documentation about available updates to root ;-) and hope that this makes this mail less off-topic here *g* - I need a bit help from XML/XSLT experts which I expect to be in the doc team ;-) In short: I have written a xsl file that filters the output of zypp-checkpatches-wrapper to send an update notification mail to root. It basically works, however I have some problems with the whitespace. Current output: --------------------------------------------------------------------- # xsltproc patch2mail.xsl zypp.xml *** ERROR *** Some error during calculation happened *** ERROR *** Another error Update sources: ftp.gwdg.de (http://ftp.gwdg.de/pub/suse/update/10.1) irgendwo (http://ftp.irgendwo.de) === java-1_5_0-sun - Patch 1438-0 (security) === SUN Java packages prior 1.5.0 update 7 allow DOS. Sun Java Runtime Environment (JRE) 1.5.0_6 and earlier, JDK 1.5.0_6 and earlier, and SDK 1.5.0_6 and earlier allows remote attackers to cause a denial of service (disk consumption) by using the Font.createFont function to create temporary files of arbitrary size in the %temp% directory (CVE-2006-2426). === java-1_5_0-sun - Patch 1438-0 (security) === SUN Java packages prior 1.5.0 update 7 allow DOS. Sun Java Runtime Environment (JRE) 1.5.0_6 and earlier, JDK 1.5.0_6 and earlier, and SDK 1.5.0_6 and earlier allows remote attackers to cause a denial of service (disk consumption) by using the Font.createFont function to create temporary files of arbitrary size in the %temp% directory (CVE-2006-2426). Total updates: 2 (2 security) __TOTAL__22__ --------------------------------------------------------------------- The fact that the same patch is listed twice is caused by my test file (zypp.xml, attached) - don't worry about this ;-) Also don't worry about the __TOTAL__ line - this is easier to parse by my script. I'd like to have - no empty at the very beginning - "*** ERROR ***", "Update sources" and "=== ... ===" without leading whitespace - an empty line after the patch summary - less empty lines before "Total updates" Can someone help me with these issues? The xslt and the script calling it are attached to this mail, also the test data (zypp.xml) I used. Regards, Christian Boltz, searching for a good sig ;-) -- xslt, was? Wir kombinieren das Paradigma von awk mit der sprachlichen Eleganz von Cobol und den programmiertechnischen Verrenkungen von funktionalen Sprachen unter sorgfältiger Umgehung aller möglichen Vorteile. [Kristian Köhntopp]
Hi Christian, On Donnerstag, 8. März 2007, Christian Boltz wrote:
[...] I want to mail some documentation about available updates to root ;-) and hope that this makes this mail less off-topic here *g* - I need a bit help from XML/XSLT experts which I expect to be in the doc team ;-)
In short: I have written a xsl file that filters the output of zypp-checkpatches-wrapper to send an update notification mail to root.
It basically works, however I have some problems with the whitespace.
Basically, it is a good idea to use xsl:text and xsl:strip-space and/or xsl:preserve-space. Especially if you want exact control of your whitespace. It can be a bit tricky to find the correct combination though. :)
[...]
I'd like to have - no empty at the very beginning - "*** ERROR ***", "Update sources" and "=== ... ===" without leading whitespace - an empty line after the patch summary - less empty lines before "Total updates"
Can someone help me with these issues?
See the attached XSLT file. It gives me the following output: $ xsltproc patch2mail.xsl zypp.xml *** ERROR *** Some error during calculation happened *** ERROR *** Another error Update sources: ftp.gwdg.de (http://ftp.gwdg.de/pub/suse/update/10.1) irgendwo (http://ftp.irgendwo.de) === java-1_5_0-sun- Patch 1438-0(security) === SUN Java packages prior 1.5.0 update 7 allow DOS. Sun Java Runtime Environment (JRE) 1.5.0_6 and earlier, JDK 1.5.0_6 and earlier, and SDK 1.5.0_6 and earlier allows remote attackers to cause a denial of service (disk consumption) by using the Font.createFont function to create temporary files of arbitrary size in the %temp% directory (CVE-2006-2426). === java-1_5_0-sun- Patch 1438-0(security) === SUN Java packages prior 1.5.0 update 7 allow DOS. Sun Java Runtime Environment (JRE) 1.5.0_6 and earlier, JDK 1.5.0_6 and earlier, and SDK 1.5.0_6 and earlier allows remote attackers to cause a denial of service (disk consumption) by using the Font.createFont function to create temporary files of arbitrary size in the %temp% directory (CVE-2006-2426). Total updates: 2 (2 security) __TOTAL__22__ Bye, Tom -- ---------------------------------------------------------------------- SUSE LINUX Products GmbH >o) Documentation Team Maxfeldstrasse 5 /\\ Technical Editor 90409 Nuernberg, Germany _\_v http://en.opensuse.org/Documentation_Team
Hello, on Donnerstag, 8. März 2007, Thomas Schraitle wrote:
On Donnerstag, 8. März 2007, Christian Boltz wrote:
In short: I have written a xsl file that filters the output of zypp-checkpatches-wrapper to send an update notification mail to root.
It basically works, however I have some problems with the whitespace.
Basically, it is a good idea to use xsl:text and xsl:strip-space and/or xsl:preserve-space. Especially if you want exact control of your whitespace. It can be a bit tricky to find the correct combination though. :)
"a bit"?!? ;-)
I'd like to have [...] Can someone help me with these issues?
See the attached XSLT file. It gives me the following output: [...]
That looks much better, thanks. And I even understand what you do ;-) so I could make some more modifications. I now get the following result which looks how I want it: # xsltproc patch2mail_ts_cb.xsl zypp.xml |grep -v __TOTAL *** ERROR *** Some error during calculation happened *** ERROR *** Another error Update sources: - ftp.gwdg.de (http://ftp.gwdg.de/pub/suse/update/10.1) - irgendwo (http://ftp.irgendwo.de) === java-1_5_0-sun - Patch 1438-0 (security) === SUN Java packages prior 1.5.0 update 7 allow DOS. Sun Java Runtime Environment (JRE) 1.5.0_6 and earlier, JDK 1.5.0_6 and earlier, and SDK 1.5.0_6 and earlier allows remote attackers to cause a denial of service (disk consumption) by using the Font.createFont function to create temporary files of arbitrary size in the %temp% directory (CVE-2006-2426). === java-1_5_0-sun - Patch 1438-0 (security) === SUN Java packages prior 1.5.0 update 7 allow DOS. Sun Java Runtime Environment (JRE) 1.5.0_6 and earlier, JDK 1.5.0_6 and earlier, and SDK 1.5.0_6 and earlier allows remote attackers to cause a denial of service (disk consumption) by using the Font.createFont function to create temporary files of arbitrary size in the %temp% directory (CVE-2006-2426). -------------------------------------------------------- Total: 2 updates (2 security) Thanks for your help! My updated xslt file is attached to this mail (also tested with no errors, no available updates and available updates without errors). I'll post this to opensuse-factory in the next days also - maybe it's something that might be interesting for 10.3... Regards, Christian Boltz, again searching for a xsl-sig ;-) -- Eine "Sprache", in der man <xsl:call-template name="foo"> <xsl:with-param name="arg">blubber</xsl:with-param> </xsl:call-template> schreiben muß, wo jeder andere foo(blubber) schreibt, *muß* irgendwie ein Erfolg werden. Jedenfalls für Festplatten- und Speicherverkäufer. [Stefan Reuther]
Hi, On Donnerstag, 8. März 2007, Christian Boltz wrote:
[...]
Basically, it is a good idea to use xsl:text and xsl:strip-space and/or xsl:preserve-space. Especially if you want exact control of your whitespace. It can be a bit tricky to find the correct combination though. :)
"a bit"?!? ;-)
Hehe, no comment. ;-)
See the attached XSLT file.
[...]
That looks much better, thanks.
And I even understand what you do ;-) so I could make some more modifications.
Yesterday I forgot to ask: Why did you use XSLT 1.1? I suspect you need them because of the xsl:document. However, XSLT 1.1 was an "intermediate step" the latest version is 2.0. As far as I know the former never reached recommendation status. Unfortunatly, at the moment only Saxon can process XSLT 2.0 (or 1.1?) stylesheets. You will loose a lot of compatibility by using XSLT 1.1/2.0. If you really need xsl:document, I can recommend EXSLT's exsl:document function: See http://www.exslt.org/exsl/elements/document/index.html It has a similiar functionality like xslt:document and it is supported by libxslt.
[...] Christian Boltz, again searching for a xsl-sig ;-)
It doesn't matter how many steps it takes as long as it's fun, right? --Norman Walsh ;-) Bye, Tom -- Thomas Schraitle ---------------------------------------------------------------------- SUSE LINUX GmbH >o) Documentation Specialist Maxfeldstrasse 5 /\\ 90409 Nuernberg _\_v http://en.opensuse.org/Documentation_Team --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-doc+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-doc+help@opensuse.org
Hello, on Freitag, 9. März 2007, Thomas Schraitle wrote:
On Donnerstag, 8. März 2007, Christian Boltz wrote: [...] Yesterday I forgot to ask: Why did you use XSLT 1.1? I suspect you need them because of the xsl:document. However, XSLT 1.1 was an "intermediate step" the latest version is 2.0. As far as I know the former never reached recommendation status.
The answer is more simple than you might think - the file I used as "template" was using 1.1 and I did not even think about changing it ;-)
Unfortunatly, at the moment only Saxon can process XSLT 2.0 (or 1.1?) stylesheets. You will loose a lot of compatibility by using XSLT 1.1/2.0. If you really need xsl:document, I can recommend EXSLT's exsl:document function:
See http://www.exslt.org/exsl/elements/document/index.html
It has a similiar functionality like xslt:document and it is supported by libxslt.
To make the story short: This project works as needed, and "never change a running system" - especially if XSLT is involved ;-) However, I will accept patches *g*
[...] Christian Boltz, again searching for a xsl-sig ;-)
It doesn't matter how many steps it takes as long as it's fun, right? --Norman Walsh
XSLT and fun? I usually get headache. OK, it wasn't a big problem with this small file, but I had "some" bad experience with the XLS files for the german SUSE Linux FAQ... Norman Walsh wasn't talking about XSLT, was he? [1] Regards, Christian Boltz, again searching for a sig... [1] Wait: Google says "Norman Walsh is an XML Standards Architect". He must have been working on something else at this time ;-) -- [PDF] Fipptehler korrigiert -- wie konnten wir das bisher uebersehen ;) - <xsl:if test="position()=1">Schüsselworte: </xsl:if> + <xsl:if test="position()=1">Schlüsselworte: </xsl:if> [David Haller in suse-linux-faq] --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-doc+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-doc+help@opensuse.org
Hi, On Freitag, 9. März 2007, Christian Boltz wrote:
[...]
Yesterday I forgot to ask: Why did you use XSLT 1.1? I suspect you need them because of the xsl:document. However, XSLT 1.1 was an "intermediate step" the latest version is 2.0. As far as I know the former never reached recommendation status.
The answer is more simple than you might think - the file I used as "template" was using 1.1 and I did not even think about changing it ;-)
Ahh, ok.
[...] However, I will accept patches *g*
As usual. :-)
[...] Christian Boltz, again searching for a xsl-sig ;-)
It doesn't matter how many steps it takes as long as it's fun, right? --Norman Walsh
XSLT and fun?
As always it is a matter of taste.
I usually get headache. OK, it wasn't a big problem with this small file, but I had "some" bad experience with the XLS files for the german SUSE Linux FAQ...
From my work with XSLT, you get headache when * your XML sucks. Really, some XML is so deeply wrong structured that it takes you a glass of Aspirin (at least!) to write a decent XSLT stylesheet. * you write XSLT stylesheets like a procedural programming language. * you use XSLT for something that it was not invented for. For example, creating some kind of "binary" output from the transformation. * you don't use the full potential of XSLT. For example using xsl:for-each instead of xsl:apply-templates where it is in most cases more appropriate. * you don't have a good book or a reference. :) * you don't know how to sort indices with umlauts. Arggh! In general, I get always headaches with the last point. ;-) From my daily work here I haven't found a better solution than XSLT. In most cases, XSLT is good enough. But I agree, for some parts you need Aspirin. ;-) (Maybe the situation has changed with XSLT 2.0/XPath 2.0.)
Norman Walsh wasn't talking about XSLT, was he? [1]
I can't remember, but I suspect he is always talking about DocBook, XML, XSLT and the like. :) Bye, Tom -- Thomas Schraitle ---------------------------------------------------------------------- SUSE LINUX GmbH >o) Documentation Specialist Maxfeldstrasse 5 /\\ 90409 Nuernberg _\_v http://en.opensuse.org/Documentation_Team --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-doc+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-doc+help@opensuse.org
Hello, on Freitag, 9. März 2007, Thomas Schraitle wrote:
On Freitag, 9. März 2007, Christian Boltz wrote: [...]
XSLT and fun?
As always it is a matter of taste.
;-)
I usually get headache. OK, it wasn't a big problem with this small file, but I had "some" bad experience with the XLS files for the german SUSE Linux FAQ...
From my work with XSLT, you get headache when
* your XML sucks. Really, some XML is so deeply wrong structured that it takes you a glass of Aspirin (at least!) to write a decent XSLT stylesheet.
Hmm, I wouldn't call the FAQ XML wrong structured ;-)
* you write XSLT stylesheets like a procedural programming language.
Maybe, we took the XLST from php-faq.de and modified it for our needs.
* you use XSLT for something that it was not invented for. For example, creating some kind of "binary" output from the transformation.
no, just HTML (and LaTeX, but that one is not really problematic).
* you don't use the full potential of XSLT. For example using xsl:for-each instead of xsl:apply-templates where it is in most cases more appropriate.
Hmmm... cb@cboltz:~/suse-linux-faq/dtd/html> grep for-each * |wc -l 73 cb@cboltz:~/suse-linux-faq/dtd/html> grep apply-templates * |wc -l 13
* you don't have a good book or a reference. :)
Good point ;-)
* you don't know how to sort indices with umlauts. Arggh!
In general, I get always headaches with the last point. ;-)
*g* Another headache candidate: * you need a table of content / menu _and_ (part of the) content in the same output file (this explains why the LaTeX output was easier - it does the TOC automatically) If you have some free time and are interested, you can have a look at it: cvs -d :pserver:anonymous@koehntopp.de:/faq co suse-linux-faq (Needless to say: it works, but patches to make it nicer are accepted.)
From my daily work here I haven't found a better solution than XSLT.
Maybe, if you have to handle XML. (Kris Köhntopp recommended some newer PHP functions once, but I didn't test them yet.) My solution is usually to avoid XML and therefore XSLT if possible. (This does not mean that XML itsself is bad - but handling it...)
In most cases, XSLT is good enough. But I agree, for some parts you need Aspirin. ;-)
| addsig *g* Regards, Christian Boltz, apropos Kris Köhntopp... -- xslt, was? Wir kombinieren das Paradigma von awk mit der sprachlichen Eleganz von Cobol und den programmiertechnischen Verrenkungen von funktionalen Sprachen unter sorgfältiger Umgehung aller möglichen Vorteile. [Kristian Köhntopp] --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-doc+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-doc+help@opensuse.org
Hi, On Sonntag, 11. März 2007, Christian Boltz wrote:
[...]
I usually get headache. OK, it wasn't a big problem with this small file, but I had "some" bad experience with the XLS files for the german SUSE Linux FAQ...
From my work with XSLT, you get headache when [...]
My list was not meant as criticism of your files, it was more a *general* rant. ;) I don't say, XML/XSLT is the solution for everything. However, I saw many XML files and XSLT stylesheet broken by design but the author vociferous complains about the deficiancies of XML/XSLT instead of reconsidering his/her style. :) (Again, it's not a criticism of your files.)
[...]
* you don't use the full potential of XSLT. For example using xsl:for-each instead of xsl:apply-templates where it is in most cases more appropriate.
Hmmm...
cb@cboltz:~/suse-linux-faq/dtd/html> grep for-each * |wc -l 73 cb@cboltz:~/suse-linux-faq/dtd/html> grep apply-templates * |wc -l 13
In most cases xsl:for-each is considered bad style. :) XSLT is *not* Perl, Python, Ruby, ... Here are some articles that I think are worth reading: * How Not to Use XSLT http://www2.sims.berkeley.edu/academics/courses/is290-8/s04/lectures/5/drago... * Shortening XSLT Stylesheets http://www.xml.com/pub/a/2003/06/11/short-xslt.html * Five XSLT Basics (November 26, 2003) http://www.xml.com/pub/a/2003/11/26/learnXSLT.html * XSLT Questions and Answers http://www.dpawson.co.uk/xsl/sect2/sect21.html
Another headache candidate:
* you need a table of content / menu _and_ (part of the) content in the same output file (this explains why the LaTeX output was easier - it does the TOC automatically)
Hmn, I am not sure, if I understand your problem completely.
[...]
In most cases, XSLT is good enough. But I agree, for some parts you need Aspirin. ;-)
| addsig *g*
;-) Bye, Tom -- Thomas Schraitle ---------------------------------------------------------------------- SUSE LINUX GmbH >o) Documentation Specialist Maxfeldstrasse 5 /\\ 90409 Nuernberg _\_v http://en.opensuse.org/Documentation_Team --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-doc+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-doc+help@opensuse.org
Hello, on Montag, 12. März 2007, Thomas Schraitle wrote:
On Sonntag, 11. März 2007, Christian Boltz wrote:
[...]
I usually get headache. OK, it wasn't a big problem with this small file, but I had "some" bad experience with the XLS files for the german SUSE Linux FAQ...
From my work with XSLT, you get headache when [...]
My list was not meant as criticism of your files, it was more a *general* rant. ;)
I understood it as such - and I checked my files against it ;-)
I don't say, XML/XSLT is the solution for everything. However, I saw many XML files and XSLT stylesheet broken by design but the author vociferous complains about the deficiancies of XML/XSLT instead of reconsidering his/her style. :) (Again, it's not a criticism of your files.)
np ;-)
[...]
* you don't use the full potential of XSLT. For example using xsl:for-each instead of xsl:apply-templates where it is in most cases more appropriate.
Hmmm...
cb@cboltz:~/suse-linux-faq/dtd/html> grep for-each * |wc -l 73 cb@cboltz:~/suse-linux-faq/dtd/html> grep apply-templates * |wc -l 13
In most cases xsl:for-each is considered bad style. :) XSLT is *not* Perl, Python, Ruby, ...
... and, in my case, especially not PHP *g*
Here are some articles that I think are worth reading:
* How Not to Use XSLT
Reminds me of http://www.kasper-online.de/goldmail/ and http://www.karzauninkat.com/Goldhtml/goldhtml.htm *g* (both german)
[...]
Thanks for the links - I'll have a look at them when I find some free time.
Another headache candidate:
* you need a table of content / menu _and_ (part of the) content in the same output file (this explains why the LaTeX output was easier - it does the TOC automatically)
Hmn, I am not sure, if I understand your problem completely.
Have a look at http://suse-linux-faq.koehntopp.de (or any subpage). Basically, we need the content of the XML file twice to generate one HTML file: - first for the menu (left column) - second for the content So the workflow is: - parse the XML to generate the menu - "rewind" the XML file - parse the XML again to generate the content (content = table of contents | chapter | question with answer) This caused some[tm] headache and makes the HTML generation ways more difficult than the LaTeX generation (because LaTeX generates the "Menu" automatically). Additionally: As already said, we aren't the original author of the XSLT files - and you might know that understanding other people's code can be difficult ;-) And to make it even more funny, we have switches to generate an all-questions-in-one-HTML-file version and another one with links visible that is later lynx -dump'ed to text/plain. In short: It works, and I'm very happy about that - because it means I don't have to touch it ;-)) Regards, Christian Boltz -- [nach Update auf SuSE 9.3] Jetzt habe ich nur ein neues Problem: Es ist doch echt stinklangweilig, wenn's nix mehr zu frickeln gibt...;-) [Friedemann Garvelmann in suse-laptop] --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-doc+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-doc+help@opensuse.org
participants (2)
-
Christian Boltz
-
Thomas Schraitle