Subject:Output ends up concatted on one line Author:don simon Date:16 Feb 2006 03:40 PM
I'm probably missing something obvious, I'm trying to output a list of IDs from an XML file where said-ID's record contains attributes with certain values. After much consternation with namespace definition, I think I've got an XSL that is selecting the correct subset of my data. However, it puts all of the rows onto a single line. If I add some garbage text after my value-of, each row ends up on it's own line. What am I missing?
Subject:Output ends up concatted on one line Author:(Deleted User) Date:16 Feb 2006 04:00 PM
Hi, Don. If you're outputting XML, then you can use this to force a new line:
<xsl:text>
</xsl:text>
If you're outputting HTML (as the <xls:output method=html/> instruction in your sample suggests), you can use a <br/> or a <p/>, but don't forget the other HTML tags for your page, like <html>, <body>, and so on.
Subject:Output ends up concatted on one line Author:Tony Lavinio Date:17 Feb 2006 08:55 AM
Some also like to write newline as <xsl:text> </xsl:text> or
<xsl:text>
</xsl:text>.
But... why is this happening? The behavior is documented in the
standard at http://www.w3.org/TR/xslt#strip but the simple way of
explaining it (along with a rationale) is this:
If an xsl:template body contains only elements, strip the whitespace,
since *most likely* the user will not want the indenting, etc. to be
included in the output.
If an xsl:template body contains only printable text, then assume the
user wants that text output.
Otherwise, the xsl:template body contains *mixed text* (that is, some
text that does not consist of all whitespace plus at least one element)
then the action should be to include both the text and the elements.
This latter case is why you see the behavior changing when you add some
random text.