[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: NEWLINES

Subject: Re: NEWLINES
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Tue, 5 Mar 2002 16:28:08 -0500
stylesheet newlines
[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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.