Re: [xsl] Whitespace between nodes

Subject: Re: [xsl] Whitespace between nodes
From: Nicholas Shanks <contact@xxxxxxxxxxxxxx>
Date: Thu, 13 May 2004 15:45:21 +0100
On 13 May 2004, at 09:26, Michael Kay wrote:

Would you agree that, in this case, it should be:
<q>
  <a href="...">...</a>
</q>

Assuming that the output method is HTML, the output should be <q><a href="...">...</a></q> whether or not indent="yes" has been set.

As I am outputting XHTML 1.1, my output method was set to xml - changing it to html gives:


Libxslt: all output serialised (no whitespace other than text nodes), same output as indent="no" (so looks fine in browser)
Saxon: works (<q><a/></q>), but indentation elsewhere follows my XSLT indentation not the HTML output
Xalan: still outputs <q> incorrectly (unchanged from output="xml")
Sablotron: same as Xalan


- I don't have MSXML or know anything about it.
Looking on msdn.microsoft.com/xml I could only find Windows versions to download.


However, as far as I can see the responses to the original question have
been very confused. I don't think it has been clearly established whether
the unwanted whitespace came (a) from whitespace-only text nodes in the
source (in which case it should be removed using xsl:strip-space), (b) from
significant whitespace in the source (in which case it should be removed
using normalize-space()), or (c) as a result of output indentation. The
remedies in the three cases are quite different.

By 'source' do you mean the XML or the XSLT file?
There is no white-space in the XML href attribute, nor is there any between <q> and </q> in the XSL, therefore (c) is the relevant one, yes?
I thought xsl:strip-space and normalise-space() only affected text nodes like " hello ", thus neither were pertinent to my query. But other respondents to my question suggest that I have misunderstood these.


I tried adding <xsl:strip-space elements="q"> to my XSLT in both xml and html output modes and all four processors were unaffected in their output in either mode. This is in line with what I had originally thought strip-space did.


On 13 May 2004, at 01:50, M. David Peterson wrote:


So yes, there is a tag (and function) that do what you need but theyre
not really magic.

Im telling you these things because as I read through your email thread
I was seeing a lot of frustration and contention with those trying to
help.

I must apologise if my emails came across badly. This was unintended, and I blame it entirely on lack of sleep :-)


And a quick trip to Michaels Kay's reference...

Where can I find this?


or Dave Pawson's FAQ would have presented a dozen examples using an element and function that
pretty much state in plain English just what it is they do.

I had read through the FAQ but nothing I saw seemed to do what I wanted.
Nor did any of my programmer-friends know. That was why I resorted to emailing this list.
I did try to search for a solution prior, honest govn'r!
Mailing lists tend to be very slow but very authoritative ways of finding out information, since those who can answer a question are often the top experts on the matter, but are often very busy too!


I've found that when there feels like there should be a simple solution
there usually is and it just takes a bit of research to find the answer.
And if after doing the research you still cant find the answer your
going to find a lot of people in here who will help you with exactly the
things you need but who will also avoid you if they feel like your not
doing anything to research it yourself and your getting frustrated with
people because theyre not giving you exactly what you want when you want
it.

Again, apologies - it was not frustration at the respondents not giving me what I wanted, but that after a few replies came in I realised my question had been misunderstood, primarily because of lack of detail on my part (sorry!). So I responded to fill in the gaps and explain the question better.


- Nick.

Current Thread