GNOME Bugzilla – Bug 128460
"-o" not creates output file if empty
Last modified: 2009-08-15 18:40:50 UTC
"xsltproc -o" saves result to a given file. If result of transformation is empty, then file is not created. But if output method is "text" and if there are no errors, then empty file should be created. Sample files: ----- <imglist.xsl> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version ="1.0"> <xsl:output method="text"/> <xsl:template match="*[@fileref]"> <xsl:value-of select="concat(@fileref,'
')"/> </xsl:template> <xsl:template match="text()" /> </xsl:stylesheet> ----- </imglist.xsl> ----- <test1.xml> <article> <graphic fileref="images/img1.png" /> <graphic fileref="images/img2.png" /> </article> ----- </test1.xml> ----- <test2.xml> <article> <para>no images</para> <para>no images</para> </article> ----- </test2.xml> When I run $ ~/p/libxml/bin/xsltproc -o list1 imglist.xsl test1.xml I get file "list1". All is ok. But when I run $ ~/p/libxml/bin/xsltproc -o list2 imglist.xsl test2.xml I expect to get empty file "list2", but there are no file at all.
Hum ... I'm not sure I want to do this. For example people using DocBook chunking may use a -o dir/filename option where dir/filename is never created but used as the base for the creation of the filenames of the actually generated files. Changing to create the resource if there is no output is a significant change, I agree this might be surprizing initially but that can be controlled from the stylesheet by simply outputting something like a single line feed for example. So I'm not tempted to change the behaviour of libxslt at this point. Daniel
Simpler workaround is to use shell redirection ">". As proper fix is a significant change, it is better to work on XML functionality, not on minor problems. Closing.