Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Problems with whitespace in output document

Reply
Thread Tools

Problems with whitespace in output document

 
 
Michael Kragh Pedersen
Guest
Posts: n/a
 
      03-14-2005
I have made an XSLT document, looking like this.

<xsl:stylesheet version="2.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput indent="yes" method="text"/>
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<xsl:apply-templates/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

Nothing fancy about that, just writing out the elements. So I get this
output, when I see it in the browser (Mozilla on Linux).

A
B
E
F

C
D

But I want for it to be flattened, so all of the elements are aligned
left. I feel like, I have tried everything, with xslutput and
normalize-string(), and I have no idea, how to remove the whitespace.

I also tried removing all the whitespace from my XML document, that
didn't help either.

Anybody with some good ideas?

Michael K. P.
 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      03-14-2005
Michael Kragh Pedersen <(E-Mail Removed)> writes:

> I have made an XSLT document, looking like this.
>
> <xsl:stylesheet version="2.0"
> xmlnssl="http://www.w3.org/1999/XSL/Transform">
> <xslutput indent="yes" method="text"/>


If you use the text output method, there is no indentation possible also
all element nodes in the result tree will be discarded, so you could
drop HTML etc from the code below and get the same result.

> <xsl:template match="/">
> <HTML>
> <HEAD>
> <TITLE></TITLE>
> </HEAD>
> <BODY>
> <xsl:apply-templates/>


Note this also applies templates to text nodes so will copy any
indentation and other white space to the output.

> </BODY>
> </HTML>
> </xsl:template>
> <xsl:template match="*">
> <xsl:apply-templates/>

similarly this.
> </xsl:template>
> </xsl:stylesheet>



Perhaps you want to add <xsl:strip-space elements="*"/> so that white
space nodes in the input are ignored, but if you output using the html
output method then unless you use <pre> or equivalent css then newlines
in the result won't render as newlines anyway si teh result should not
look like the result you show below when rendered in the browser.

> Nothing fancy about that, just writing out the elements. So I get this
> output, when I see it in the browser (Mozilla on Linux).
>
> A
> B
> E
> F
>
> C
> D
>
> But I want for it to be flattened, so all of the elements are aligned
> left. I feel like, I have tried everything, with xslutput and
> normalize-string(), and I have no idea, how to remove the whitespace.
>
> I also tried removing all the whitespace from my XML document, that
> didn't help either.
>
> Anybody with some good ideas?
>
> Michael K. P.


David
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Splitting text at whitespace but keeping the whitespace in thereturned list MRAB Python 3 01-26-2010 11:36 PM
Structure using whitespace vs logical whitespace cmdrrickhunter@yaho.com Python 10 12-16-2008 03:51 PM
[SiSU] book/document generator, sample documents: summary page for document markup and output Ralph Amissah Ruby 0 11-20-2005 03:23 PM
Whitespace where I don't want whitespace! Oli Filth HTML 9 01-17-2005 08:47 PM
controlling whitespace with output method=html Andy Fish XML 2 06-15-2004 06:08 AM



Advertisments