[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Removing nodes with text content ?
Hi Fabien,
as Martin's answer didn't let you get rid of the line breaks, I would like to remove the intermediary<phrase> nodes to avoid line breaks (which are highly desirable on other places, but here are annoying me), and thus having everything on a single line (using the docbook stylesheets, already customized). a very specific, thus "inelegant" full "answer" below, but some additional hints anyway: - to avoid line breaks in the output using normalize-space() is often useful - xsl:strip-space might help as well. <xsl:template match="phrase[@role='rtf']"> <xsl:copy> <xsl:apply-templates select="./*"/> </xsl:copy> </xsl:template> 1. If you want to remove the element, you shouldn't copy it. (On the other hand, the template for para lacks this.) 2. Why wasn't text in the output? Your select selects only element nodes. In the more general template you use correctly "node()". This should be working then (XSLT1): <xsl:output indent="yes"/> <xsl:template match="para"> <xsl:copy> <phrase> <xsl:if test=".//phrase[@role='rtf']"> <xsl:attribute name="role">rtf</xsl:attribute> </xsl:if> <xsl:apply-templates/> </phrase> </xsl:copy> </xsl:template> <xsl:template match="phrase[@role='rtf']" > <xsl:apply-templates select="node()"/> <xsl:if test="following-sibling::phrase"><xsl:text> </xsl:text></xsl:if> </xsl:template> <xsl:template match="text()"> <xsl:value-of select="normalize-space(.)"/> </xsl:template> <xsl:template match="* | @*"> <xsl:copy><xsl:apply-templates select="node() | @*"/></xsl:copy> </xsl:template> Best, Torsten -- Torsten Schassan Digitale Editionen Abteilung Handschriften und Sondersammlungen Herzog August Bibliothek, Postfach 1364, D-38299 Wolfenbuettel Tel.: +49-5331-808-130 (Fax -165), schassan {at} hab.de http://www.hab.de/forschung/projekte/europeana-regia.htm http://www.hab.de/forschung/projekte/weiss64.htm
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|