RE: [xsl] multiple + empty output

Subject: RE: [xsl] multiple + empty output
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 12 Nov 2009 10:10:34 -0000
Try adding <xsl:template match="/"><xsl:apply-templates
select="//artikel"/></xsl:template>

I suspect that the processing of the content outside (or between) the
artikel elements - perhaps only whitespace - is finding its way into the
so-called principal result tree. The output file for the principal result
tree is created only if you write something to it.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

> -----Original Message-----
> From: Szabo, Patrick (LNG-VIE) [mailto:patrick.szabo@xxxxxxxxxxxxx] 
> Sent: 12 November 2009 09:29
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] multiple + empty output
> 
> Hi, 
>  
> I'm using Saxon 9 and XSLT 2.0.
> I want to split 1 input-file in several output-files.
> The problem is that i get the multiple files plus 1 empty file.
>  
> Like this:
>  
> 1_2006.xml --> stylesheet --> file1, file2, file3, 1_2006.xml
>  
> I don't want to create this empty 1_2006.xml :(
>  
> I've tried <xsl:output 
> method="saxon:net.sf.saxon.event.Sink"/> but it doesn't seem to work.
>  
> The stylesheet:
> 
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:saxon="http://saxon.sf.net/"; 
> exclude-result-prefixes="#all"> <xsl:strip-space 
> elements="zs_absatz"/> <xsl:output 
> method="saxon:net.sf.saxon.event.Sink"/>
> <xsl:output method="xml" encoding="ISO-8859-1" name="output"/>
> <!-- ========================================================== -->
> <!-- Stylesheet: splitartikel -->
> <!-- pro Beitrag eine Datei -->
> <!-- 
> ========================================================== 
> --> <xsl:template match="artikel">
> 	<xsl:variable name="filename">
> 		<xsl:text>../step12/MuR_</xsl:text>
> 		<xsl:value-of
> select="format-number(descendant::jahrgang[1], '0000')"/>
> 		<xsl:text>_</xsl:text>
> 		<xsl:choose>
> 			<xsl:when
> test="not(contains(descendant::ausgabe[1], '-'))">
> 				<xsl:value-of
> select="format-number(descendant::ausgabe[1], '00')"/>
> 			</xsl:when>
> 			<xsl:otherwise>
> 				<xsl:value-of
> select="descendant::ausgabe[1]"/>
> 			</xsl:otherwise>
> 		</xsl:choose> 
> 		<xsl:text>_</xsl:text>
> 		<xsl:value-of
> select="format-number(descendant::seite-von[1], '000')"/>
> 		<xsl:if test="descendant::position">
> 			<xsl:text>_</xsl:text>
> 			<xsl:value-of select="descendant::position[1]"/>
> 		</xsl:if>
> 		<xsl:text>.xml</xsl:text>
> 	</xsl:variable> 
> 
> 	<xsl:result-document href="{$filename}" format="output">
> 		<xsl:copy-of select="."/>
> 	</xsl:result-document>
> </xsl:template>
> </xsl:stylesheet>
>  
> 
> Idea anyone ?!
> 
> regards
> 
> 
> Patrick Szabo
>  XSLT-Entwickler 
> 
> Tel.: +43 (1) 534 52 - 1573 
> Fax: +43 (1) 534 52 - 146 
> 
> Patrick.Szabo@xxxxxxxxxxxxx
> 
> LexisNexis Verlag ARD Orac GmbH & Co KG
> Marxergasse 25, 1030 Wien
> FN 8333f, Handelsgericht Wien
> http://www.lexisnexis.at/

Current Thread