Hello,
sorry for abusing this list for XSLT questions, but well, some people here (hello Thomas!) are too good in this area ;-)
I have two small issues with my patch2mail (update notification) script: It includes two lines at the end of the output which I'd like to supress:
<?xml version="1.0"?> Daten des Repositorys laden...Installierte Pakete lesen...
The first one is obviously the XML "header", the second one is composed from two <message type="info">...</message> lines.
The current XSLT file is attached - you can feed it with zypper --xmlout -t patch | xsltproc patch2mail.xsl - if you want to test it.
What do I have to change to remove the above lines? (Note: Only messages with type "info" should be hidden.)
Regards,
Christian Boltz
Hi,
On Friday 21 November 2008, Christian Boltz wrote:
[...] I have two small issues with my patch2mail (update notification) script: It includes two lines at the end of the output which I'd like to supress:
<?xml version="1.0"?> Daten des Repositorys laden...Installierte Pakete lesen...
The first one is obviously the XML "header",
Yes, the header is the XML declaration. That's easy to omit it: Insert a <xsl:output method="text"/> right after the xsl:stylesheet element.
the second one is composed from two <message type="info">...</message> lines.
The current XSLT file is attached - you can feed it with zypper --xmlout -t patch | xsltproc patch2mail.xsl - if you want to test it.
That doesn't work for me. If I use only the first part, I get:
<?xml version='1.0'?> <stream> <message type="error">--terse is not implemented, does nothing</message> <message type="error">Unknown command 'patch'</message> <message type="info">Type 'zypper help' to get a list of global options and commands.</message> </stream>
# zypper --version zypper 0.11.10
What do I have to change to remove the above lines? (Note: Only messages with type "info" should be hidden.)
First, fix your stylesheet. :) It contains version="1.1". As far as I know, this version is not really supported by libxslt. Use version="1.0". Especially the xsl:document element is unknown in the XSLT 1.0 specification. If you really need this functionality, use the document element from the EXSLT initiative, see [1].
I guess, you need a new template with match="text()" or match="message/text()" somewhere, but that could be a bit too radical.
Bye, Tom
------ [1] http://www.exslt.org/exsl/elements/document/index.html
Hello,
(finally found some time to work on this...)
on Montag, 24. November 2008, Thomas Schraitle wrote:
On Friday 21 November 2008, Christian Boltz wrote:
[...] I have two small issues with my patch2mail (update notification) script: It includes two lines at the end of the output which I'd like to supress:
<?xml version="1.0"?> Daten des Repositorys laden...Installierte Pakete lesen...
The first one is obviously the XML "header",
Yes, the header is the XML declaration. That's easy to omit it: Insert a <xsl:output method="text"/> right after the xsl:stylesheet element.
Indeed, that helps. There was a xsl:output tag sitting around already, but commented out - unfortunately I don't remember why I disabled it (might be because it included an encoding flag).
Nevertheless: Works _with_ the xsl:output tag :-)
I also changed my wrapper script to call zypper always with LANG=C because I got some warnings about non-UTF8 input (I still use ISO-8859-15 locale).
The current XSLT file is attached - you can feed it with zypper --xmlout -t patch | xsltproc patch2mail.xsl - if you want to test it.
That doesn't work for me. If I use only the first part, I get:
<?xml version='1.0'?>
<stream> <message type="error">--terse is not implemented, does nothing</message>
...
# zypper --version zypper 0.11.10
That's an outdated zypper version ;-) - openSUSE 11.1 has zypper 1.0.2.
I'll attach zypper output from 11.1 (and the updated XSLT file) in case you want to test it.
What do I have to change to remove the above lines? (Note: Only messages with type "info" should be hidden.)
First, fix your stylesheet. :) It contains version="1.1". As far as I know, this version is not really supported by libxslt. Use version="1.0". Especially the xsl:document element is unknown in the XSLT 1.0 specification.
I changed the version and removed the xsl:document "wrap" around the xsl:apply-templates for <update-status /> - still seems to work.
If you really need this functionality, use the document element from the EXSLT initiative, see [1].
The only functionality I need is "parse the XML and output text/plain". I don't really care how or why it works as long as it works ;-)
I guess, you need a new template with match="text()" or match="message/text()" somewhere, but that could be a bit too radical.
I found a working solution:
<!-- messages, unless type="info" --> <xsl:template match="message"> <xsl:if test="@type != 'info'"> xsl:text ERROR: </xsl:text> <xsl:apply-templates /> xsl:text </xsl:text> </xsl:if> </xsl:template>
Thanks for your help!
Regards,
Christian Boltz
Hi,
On Monday 08 December 2008, Christian Boltz wrote:
[...]
# zypper --version zypper 0.11.10
That's an outdated zypper version ;-) - openSUSE 11.1 has zypper 1.0.2.
I thought so. :)
I'll attach zypper output from 11.1 (and the updated XSLT file) in case you want to test it.
Looks good. No complains so far. ;-)
[...]
If you really need this functionality, use the document element from the EXSLT initiative, see [1].
The only functionality I need is "parse the XML and output text/plain". I don't really care how or why it works as long as it works ;-)
Well, you need it when you want to have more than one output files.
[...] I found a working solution:
<!-- messages, unless type="info" -->
<xsl:template match="message"> <xsl:if test="@type != 'info'"> xsl:text ERROR: </xsl:text> <xsl:apply-templates /> xsl:text </xsl:text> </xsl:if> </xsl:template>
You can omit the xsl:if clause with a predicate in "match" to make it a bit more compact:
<xsl:template match="message[@type='info']"> xsl:text ERROR: </xsl:text> <xsl:apply-templates /> xsl:text </xsl:text> </xsl:template>
Maybe you need a another template to deal with general message elements or with other message elements that contains other values in your @type attributes. I haven't tested it. With your given XML file both templates work.
Well, it's a matter of style not of functionality. :)
Tom
Hello,
on Dienstag, 9. Dezember 2008, Thomas Schraitle wrote:
On Monday 08 December 2008, Christian Boltz wrote:
...
I'll attach zypper output from 11.1 (and the updated XSLT file) in case you want to test it.
Looks good. No complains so far. ;-)
Thanks for checking it!
[...]
If you really need this functionality, use the document element from the EXSLT initiative, see [1].
The only functionality I need is "parse the XML and output text/plain". I don't really care how or why it works as long as it works ;-)
Well, you need it when you want to have more than one output files.
Then I really don't need it. There's only one /dev/stdout ;-)
[...] I found a working solution:
<!-- messages, unless type="info" -->
<xsl:template match="message"> <xsl:if test="@type != 'info'">
You can omit the xsl:if clause with a predicate in "match" to make it a bit more compact:
<xsl:template match="message[@type='info']">
^ Shouldn't it be "!=" instead of "="?
Maybe you need a another template to deal with general message elements or with other message elements that contains other values in your @type attributes. I haven't tested it. With your given XML file both templates work.
Well, it's a matter of style not of functionality. :)
Then I'll keep the xsl:if ;-) and commit an updated patch2mail to the buildservice later.
Regards,
Christian Boltz
Hi,
On Tuesday 09 December 2008, Christian Boltz wrote:
[...]
[...] I found a working solution:
<!-- messages, unless type="info" -->
<xsl:template match="message"> <xsl:if test="@type != 'info'">
You can omit the xsl:if clause with a predicate in "match" to make it a bit more compact:
<xsl:template match="message[@type='info']">
^
Shouldn't it be "!=" instead of "="?
Ahh, you're right.
Maybe you need a another template to deal with general message elements or with other message elements that contains other values in your @type attributes. I haven't tested it. With your given XML file both templates work.
Well, it's a matter of style not of functionality. :)
Then I'll keep the xsl:if ;-) and commit an updated patch2mail to the buildservice later.
Whatever you like. Just to show you another possibilitiy. :)
Tom
Christian Boltz opensuse@cboltz.de writes:
I also changed my wrapper script to call zypper always with LANG=C because I got some warnings about non-UTF8 input (I still use ISO-8859-15 locale).
But why? The sooner you switch, the better. These days, using a non-UTF-8 encoding just hurts.
Hello,
on Dienstag, 9. Dezember 2008, Karl Eichwalder wrote:
Christian Boltz opensuse@cboltz.de writes:
I also changed my wrapper script to call zypper always with LANG=C because I got some warnings about non-UTF8 input (I still use ISO-8859-15 locale).
But why? The sooner you switch, the better.
Well, there are different reasons. For example, I have several webservers running with ISO-8859-15. Uploading HTML documents with UTF-8 encoding causes some interesting charset problems. And I'm not planning to switch these servers to UTF-8 because this would mean to change lots of (often customer's) files...
These days, using a non-UTF-8 encoding just hurts.
Well, it depends (see above) and I don't really need klingon characters for my daily work.
Oh, and using ISO-8859-15 is quite useful while betatesting - I found several charset problems this way which would have been unnoticed otherwise ;-)
Regards,
Christian Boltz
Christian Boltz opensuse@cboltz.de writes:
Oh, and using ISO-8859-15 is quite useful while betatesting - I found several charset problems this way which would have been unnoticed otherwise ;-)
I'd rather say this encoding is the problem ;)