[xslt] Adding newline changes output formatting
- From: Albert Chin <xslt mlists thewrittenword com>
- To: xslt gnome org
- Subject: [xslt] Adding newline changes output formatting
- Date: Thu, 6 Feb 2003 13:05:34 -0600
I have XML input:
<?xml version="1.0"?>
<packages>
<package>
<category>Applications/Internet</category>
<install-name>test</install-name>
</package>
</packages>
and want to duplicate this as output using the XSLT input:
<xsl:template match="/">
<xsl:element name="packages">
<xsl:for-each select="packages/package">
<xsl:element name="package">
<xsl:copy-of select="category"/>
<xsl:if test="string(category)">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:copy-of select="install-name"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
Using xsltproc 1.0.23 I get:
<?xml version="1.0"?>
<packages>
<package><category>Applications/Internet</category>
</package>
</packages>
If I remove:
<xsl:if test="string(category)">
<xsl:text> </xsl:text>
</xsl:if>
I get:
<?xml version="1.0"?>
<packages>
<package>
<category>Applications/Internet</category>
</package>
</packages>
I want to duplicate the original input file. It seems like as soon as
the newline is printed, indenting is disabled.
I posted to xsl-list and someone suggested:
<xsl:strip-space elements="package"/>
but it didn't have any effect.
--
albert chin (china@thewrittenword.com)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]