Re: whitespace and accessing xmltree from script

Subject: Re: whitespace and accessing xmltree from script
From: Tyler Baker <tyler@xxxxxxxxxxx>
Date: Tue, 26 Jan 1999 07:57:15 -0500
Mattias Konradsson wrote:

> There's a mention of  a <xsl:space="preserve"> tag but it doesnt seem to
> work, I'm 100% sure where it should be places either, within templates?
>
> Another question, is it possible to access nodes and attributes
> from jscript that  define with <xsl:script language="JScript">
> and call with eval, like say I want to do a function that takes the
> attribute of the element, formats it in a certain way and spits it back.
>
> Sorry for all the questions folks btw, It's just that the MS documentation
> seems to be pretty scarse , gee, couldnt they have included some more
> examples on sitebuilder.

You must be confused with xml:space which the XSL draft uses and should be
removed because I have found that providing this feature makes working with
the DOM too inefficient to bother supporting it plus there is the redundancy
issue with xsl:strip-space and xsl:preserve-space.  I think that
xsl:strip-space and xsl:preserve-space are good enough and are much cleaner in
terms of their use in XSL (XSL is supposed to be in control of the
transformation process, not the source tree).

In order to have DOM support, for each TextNode you need to search for the
first ancestor you find which has an xml:space attribute.  99.999% of the time
you will not find any xml:space attribute so supporting xml:space in XSL
causes the XSL to waste a ton of processing time for something that will be
extremely rare in use and arguably not useful.  Of course you can index things
as you build the DOM tree, but then in that case you have totally thrown
standard DOM out the window.

The only other option I can think of is to iterate over the entire DOM tree
and do the indexing via a table mapping nodes to whitespace preserving values,
but that I don't think that is worth the cost to support xml:space...

If anyone has any better algorithm for solving this problem, then I am all
ears...

Tyler


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


Current Thread