Trevor Nicholls wrote:
Thank you Abel
[...snip...]
<xsl:when test="not(preceding-sibling::*)[starts-with($Arg,'
')]">
<xsl:call-template name="WS">
[...snip...]
OK, the foregoing is invalid 1.0. So I tried modifying it to this:
<xsl:when test="not(preceding-sibling::*) and starts-with($Arg,'
')">
<xsl:call-template name="WS">
Now there are no reported errors, but the test appears not to be working (at
least, there is an extra leading space in the output document wherever this
template has been called, compared with what Saxon was producing with the
original test).
In all honesty, I haven't delved into your stylesheet logic. What you
are testing above is whether the current node has a preceding sibling
element and whether $Arg starts with a newline character.
You don't show how the original template is called. You select the
current node into $Arg (which could contain any number of children) and
then you use string functions on that node, which essentially normalizes
that node into a string, giving you no way whatsoever to extract any
elements from it (they will all be stringized).
Is that what you want? Is that expected behavior?
If you want to remove the newlines you could make it easier on yourself
by using:
translate($Arg, '
', '')
You also seem to have special cases. Why not use the template techniques
for those cases? Let XSLT decide for you:
<xsl:template match="text()[following-sibling::nl]">
....
<xsl:template match="text()">
....
Then your KeepWS and WS named templates will become easier to program.
HTH,
Cheers,
-- Abel --
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--