|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








