Subject: RE: [xsl] Preserve Whitespace with Mixed Content (Text and Tags) From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 12 May 2005 23:20:35 +0100 |
Are you using Microsoft's XSLT processor? If so, the best advice is don't: it removes the whitespace before you get any chance in your stylesheet to preserve it. The other question is, do you want white space in the HTML "source", or white space on the browser screen? They aren't the same thing: the browser collapses multiple spaces and newlines into a single space. To convert multiple spaces in the XML into multiple spaces on the screen, you may need to change them into non-breaking spaces (But you're using <pre> tags, so I guess you know that). Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: James.Whitehead-1@xxxxxxxxxxxx > [mailto:James.Whitehead-1@xxxxxxxxxxxx] > Sent: 12 May 2005 22:56 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Preserve Whitespace with Mixed Content (Text and Tags) > > Hello, > Message-Id: <iss.609c.4283d0df.801be.1@xxxxxxxxxxxxxxxxxx> > > I am generating html from an xml document, and would like to > preserve white space inside tags that contain both text and > other tags, such within these THD tags: > <THD> <HL1>Load</HL1> <HL1>Height</HL1></THD> > > Ideally, I would like to end up with: > <pre> Load Height</pre> > or, better: > <pre> <b>Load</b> <b>Height</b></pre> > > I have tried many xsl variations using using > <xsl:preserve-space... and <pre> tags, but am unable to come > up with a way to preserve the spaces (and line feeds) with > this mixed content. I always seem to end up with something > like either: > <pre>Load Height</pre> > or: > <pre>LoadHeight</pre> > > I have no trouble preserving white space if the inner tags > are removed, such as here: > <THD> Load Height</THD> > The <HL1> tags are not the only tags that might appear inside > the <THD> tags -- a large number of other nested tags might > show up as well. I do not have any control over the original > source xml document. > > Can anyone please point me in the right direction? I have > searched Dave Pawson's FAQ, the XSL-List archives, and other > some oft-cited web references, and if the answer is in one of > these, I haven't seen it. > > Thank you for any information you can provide. > > Regards, > > Jim
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Preserve Whitespace with , David Carlisle | Thread | [xsl] How to select a node with par, chris |
RE: [xsl] Better include them in th, Michael Kay | Date | Re: [xsl] Better include them in th, Brian Chrisman |
Month |