Subject: [xsl] losing significant whitespace with normalize-space From: "Bradford, Denis" <denisb@xxxxxxxxxxxx> Date: Tue, 16 Jul 2002 15:22:03 -0400 |
Generating text output (an apropos file) from a docbook reference manual, I'm not able to preserve whitespace around the inline <command> elements in the <refpurpose> element below. Code snippet: <refentry> <refnamediv> <refname> <indexterm><primary>configuration records</primary></indexterm> catcr </refname> <refpurpose>Displays configuration record created by <command>xmake</command>, <command>ymake</command> , or <command>xaudit</command> </refpurpose> The desired output is a single line, like this: catcr Displays configuration record created by xmake, ymake, or xaudit What I'm getting is this: catcr Displays configuration record created byxmake,ymake, orxaudit Using normalize-space is the only way I've found to eliminate the newlines, but then I lose the whitespace around the command elements is stripped. The preserve-space (and strip-space) functions don't seem to have any effect, presumably because refpurpose is not a text-only element. Here's the current state of the stylesheet - can anybody suggest what I'm doing wrong? <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" indent="no"/> <xsl:preserve-space elements="refpurpose"/> <xsl:template match="/"> <xsl:variable name="newline"> <xsl:text> </xsl:text> </xsl:variable> <xsl:for-each select="book/reference/refentry/refnamediv"> <xsl:apply-templates select="refname"/> <xsl:apply-templates select="refpurpose"> <xsl:with-param name="refnameLen" select="string-length(refname/text())"/> <xsl:with-param name="refnameField" select="' '"/> </xsl:apply-templates> <xsl:value-of select="$newline"/> </xsl:for-each> </xsl:template> <xsl:template match="refname"> <xsl:apply-templates/> </xsl:template> <xsl:template match="refpurpose"> <xsl:param name="refnameField"/> <xsl:param name="refnameLen"/> <xsl:value-of select="substring($refnameField,$refnameLen)"/> <!-- Pad with 25 spaces minus refname --> <xsl:apply-templates/> </xsl:template> <xsl:template match="*/text()"> <xsl:value-of select="normalize-space(.)"/> </xsl:template> <xsl:template match="indexterm"></xsl:template> <xsl:template match="indexterm/primary"></xsl:template> <xsl:template match="indexterm/secondary"></xsl:template> <xsl:template match="indexterm/secondary"></xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Simple Replacement, Joerg Heinicke | Thread | Re: [xsl] losing significant whites, Jeni Tennison |
Re: [xsl] XML to EXCEL, Joerg Heinicke | Date | [xsl] node responding to ancestor n, Michael |
Month |