473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problems with whitespace in output document

I have made an XSLT document, looking like this.

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output 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 xsl:output 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.
Jul 20 '05 #1
1 1371
Michael Kragh Pedersen <m_**************@hotmail.com> writes:
I have made an XSLT document, looking like this.

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output 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 xsl:output 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
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Florian Wilhelm | last post by:
I have some easy questions, but I cant figure them out: I want to read exactly one char from stdin, there should be no need to hit enter. import sys print "Input: (y/N) ", input =...
1
by: John | last post by:
I have been trying with no result, to force Xerces parsers to ignore whitespace in my XML file. I have tried several of the NG suggested setFeature() methods in DOMParser to no avail. I have now...
8
by: Tjerk Wolterink | last post by:
Hello all, how does xsl handle white space? I know you can set domething like this for nice indentation: <xsl:output method="xhtml" indent="yes"/> But know i have xsl code like this:
2
by: Wolfgang Jeltsch | last post by:
Hello, it is often convenient to insert whitespace into an XML document in order to format it nicely. For example, take this snippet of a notional DocBook XML document: <para> This is a...
11
by: Tim Bücker | last post by:
I want to save an object of an image in a variable. I am doing this with the internet explorer with no problems using the following line: oImage = node.childNodes(0).all Now I wanted to use the...
12
by: Anna | last post by:
Hi all, I posted the same question this afternoon but my message isn't showing up, so I thought I'd give it another try.... in case you should see it later I apologize for posting the same...
3
by: Wade G. Pemberton | last post by:
Help!: I use javascript to format repetitive data from a web page input FORM into a long string , and save it as lines of comma delimited data in a text file on a Unix server. The text...
5
by: Kevin Westhead | last post by:
I'm using XslTransform to apply a transform to an XML document, however I get validation problems when parsing the resulting XML document due to invalid whitespace. I'm passing in an XPathNavigator...
9
by: amattie | last post by:
Does anyone have any idea on how I can strip the extra whitespace in the XML that shows up when I receive a response from an ASP.NET 2.0 webservice? This has been discussed before, but no one has...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.