Re: [xsl] Whitespace question

Subject: Re: [xsl] Whitespace question
From: "Christopher R. Maden" <crism@xxxxxxxxx>
Date: Tue, 18 Sep 2001 05:29:08 -0700
At 04:56 18-09-2001, Ragulf Pickaxe wrote:
Christopher R. Madsen wrote:
(What you need to do is insert the space unless there's a text node already there, which means that there was something other than just space.)


How do you check wether there is a textnode allready? I am not very good at figuring things out at the moment, sorry.

Something like preceding-sibling::node()[1]self::text(), which will be empty if the preceding node doesn't exist or is something other than a text node.


I am in the situation where I have lots of different kinds of parrent nodes before the <code1> node, so I can't use the <xsl:perseve-space="code"/> unless I wish to write this line sixty times with different elements.

You could also do <xsl:preserve-space elements="*"/>.


I need the program to add a space if there is a new node right after, only if there is a space between them:
(I): <One>bla</One> <Two>bla</Two> should keep the space, but
(II): <One>bla</One><Two>bla</Two> should not, and

In order to distinguish these two cases, you *must* preserve spaces. Once the space is stripped, they are identical, and no amount of XSLT wrangling will help.


Your options are (1) xml:space="preserve" in the original XML, (2) xsl:preserve-space in the XSLT, or (3) some switch to MSXML itself before beginning the transformation.

HTH,
Chris
--
Christopher R. Maden, Principal Consultant, HMM Consulting Int'l, Inc.
DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
<URL: http://www.hmmci.com/ > <URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4  5DFC AC52 F825 AFEC 58DA


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread