Subject: Re: [xsl] NEWLINES From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx> Date: Tue, 5 Mar 2002 16:28:08 -0500 |
[David Carlisle] > > > > } Original: > } > } <xsl:value-of select='xxx'/> > } <xsl:value-of select='yyy'/> > } > } This may produce > } > } XXX > } YYY > } > } Hacked version: > } > } <xsl:value-of select='xxx' > } /><xsl:value-of select='yyy'/> > } > } This would produce > } > } XXXYYY > } > > No. Not unless you have used xml:space within the stylesheet to force > space to be copied. > > The newline between two <xsl:value-of elements forms a white space text > node, and so will be stripped from the stylesheet before processing > begins. Your hacked version will produce the same output as your > unhacked version, the newline is ignored in both. > I apologize for confusing myself and misleading everyone. I tried to strip an example down to a minimum. In stripping it down, I went too far and forgot that the problem usually comes, not in whitespace-only nodes (as you're pointing out) , but when you introduce newlines for visual formatting of the xslt, but don't really want them in the output. Sort of the inverse situation, really, but it comes up just often enough to be worth handling quickly. Here's an illustration, sort of contrived but gives the idea. Source file: <root> <xxx>XXX</xxx> <yyy>YYY</yyy> </root> Stylesheet 1: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" /> <xsl:template match="/root"> function <xsl:value-of select='xxx'/>(){ <xsl:value-of select='yyy'/> } </xsl:template> </xsl:stylesheet> Output (screen capture from command line): function XXX(){ YYY } Stylesheet 2: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" /> <xsl:template match="/root"> function <xsl:value-of select='xxx' />(){<xsl:value-of select='yyy'/> } </xsl:template> </xsl:stylesheet> Output: function XXX(){YYY } Of course, it wouldn't matter for this bit of javascript, but it often does. Cheers, Tom P XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] NEWLINES, David Carlisle | Thread | Re: [xsl] NEWLINES, David Carlisle |
Re: [xsl] NEWLINES, David Carlisle | Date | Re: [xsl] Findings: Merging XSL:FO , Peter Davis |
Month |