If you start your xsl with the root level element it should solve the
problem.
<xsl:template match="/iCalendar">
<xsl:apply-templates select="vcalendar/vevent" />
</xsl:template>
<xsl:template match="vevent".............
-----Original Message-----
From: Neil Smith [mailto:neil(_at_)fresh-toast(_dot_)com]
Sent: Monday, April 07, 2003 10:15 AM
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Strip space in Sablotron keeps unwanted (source XML) line
breaks :-(
Hi All -
Quick question if any of you have experience of using Sabloton on Apache /
PHP platform :
I have xml file formatted for readbility as below, and in my stylesheet I'm
using <xsl:strip-space elements="iCalendar vcalendar vevent" /> to remove
the dead space.
Problem : I'm trying to output as a flat text file using Sablotron, and
unfortunately I get 3 line breaks at the top of the output, which
correspond to those in the top level elements in the source XML file.
I need to remove line breaks on output - any suggestions ? Is this a known
limitation with Sablotron or have I overlooked some output encoding magic
which will work ?
Source XML :
<iCalendar>
<vcalendar version="2.0" prodid="-//hacksw/handcal//NONSGML
1.0//EN">
<vevent id="1">
<uid>19970901T130000Z-123401(_at_)host(_dot_)com</uid>
<dtstamp>19970901T130000Z</dtstamp>
<dtstart>19970903T163000Z</dtstart>
<dtend>19970903T190000Z</dtend>
<location>Location</location>
<summary>Annual Employee Review</summary>
<description>
</vevent>
.
.
(more vevents)
.
.
</vcalendar>
</iCalendar>
Stylesheet example code :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="iCalendar vcalendar vevent" />
<xsl:preserve-space elements="description"/>
<xsl:param name="current" select="0" />
<xsl:template match="vevent">
<xsl:choose>
<xsl:when test="@id=$current">
<xsl:text>BEGIN:VCALENDAR
</xsl:text>
<xsl:text>BEGIN:VEVENT
</xsl:text>
<xsl:apply-templates select="dtstart"/>
<xsl:apply-templates select="dtend"/>
<xsl:apply-templates select="uid"/>
<xsl:apply-templates select="summary"/>
<xsl:apply-templates select="description"/>
<xsl:apply-templates select="location"/>
<xsl:text>END:VEVENT
</xsl:text>
<xsl:text>END:VCALENDAR
</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:template>
... templates ...
</xsl:stylesheet>
<xsl:output method="text" indent="no" />
Cheers,
Neil Smith.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list