xsl-list
[Top] [All Lists]

RE: Normalize-Space for a template

2003-05-02 14:00:12
[Karl J. Stubsjoen]

I tried your approach.  It works well.
Just wondering though:  is there a way to strip spaces from a 
template that
has been called?  My example of a URL and QUERY and DISPLAY 
was a pretty
simple one... if this was a much more complicated (involved) 
template, it
seems there must be a way to "STRIP" the spaces from this result.


I think you do not quite have the right mental model here.  When your
template produces a result, it is added to the result tree.  In xslt
1.0, the result tree (and its fragments) are not accessible to a
template, because a result tree fragment is a different type from a
node-set.  Of course, there are non-standard vendor extensions that do
give a template access by converting nodes in the result tree into
regular node-sets.

Thus you have to normalize spaces on the various text fragments as they
are encountered in the template, not after the template has assembled
them.  You can also normalized spaces in a variable, as long as it is
not a result tree fragment.  In practice, this means that you can
normalize variables constructed like this -

<xsl:variable name = 'var1' select='..'/>

but not ones constructed like this -

<xsl:variable name='var1'>...</xsl:variable>

However, in the first case you could have normalized the value in the
select statement anyway.

Cheers,

Tom P

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



<Prev in Thread] Current Thread [Next in Thread>