473,396 Members | 1,945 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,396 software developers and data experts.

XSL : unwanted carriage returns/white space

Hello group,

I use XSLT to output a unix shell script based on the content of an XML
file :

The XSLT :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template name="haut" match="/rhythmdb">

#!/bin/bash
cd /pub/html/zicmu2/links

<xsl:for-each select="entry">
<xsl:sort select="location"/>
ln -s "<xsl:value-of select="substring-after(location,'file://')"/>"
<xsl:choose>
<xsl:when test="starts-with(location,'file:///pub/joe/misc')">
"<xsl:value-of select="substring(location, 22)"/>"
</xsl:when>
<xsl:otherwise>
"<xsl:value-of select="substring(location, 19)"/>"
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

After conversion (with xsltproc/libxml)

#!/bin/bash
cd /pub/html/zicmu2/links
ln -s "data1"

"to_data1"

ln -s "data2"

"to data2"
So I have many unwanted carriage returns/whitspaces. (it follows the
indentation of my .XSL...)

I googled around and saw <xsl:text> ?

Didn't work 'cause my XML file has unsupported char.

Help Welcomed.

Thks.

Jul 20 '05 #1
3 2210
>>>>> "StopBsod" == StopBsod <ne**@marcfrei.org> writes:

StopBsod> After conversion (with xsltproc/libxml)

StopBsod> #!/bin/bash cd /pub/html/zicmu2/links
StopBsod> ln -s "data1"

StopBsod> "to_data1"

StopBsod> ln -s "data2"

StopBsod> "to data2"

I suggest you use concat() function. With it (and an explict $newline
variable) you can create the lines as you like.
--
Arto V. Viitanen av@cs.uta.fi
University of Tampere, Department of Computer Sciences
Tampere, Finland http://www.cs.uta.fi/~av/
Jul 20 '05 #2
In article <pa****************************@marcfrei.org>,
StopBsod <ne**@marcfrei.org> wrote:

[...]

% So I have many unwanted carriage returns/whitspaces. (it follows the
% indentation of my .XSL...)

% I googled around and saw <xsl:text> ?

This is what you want to use. If you have non-whitespace text in a template,
then all the text in the template, including all the white space, gets
copied to the result tree. If you wrap all your non-whitespace text in
xsl:text elements, then only the text in the xsl:text elements, along with
text generated by other xsl elements, will be copied.

% Didn't work 'cause my XML file has unsupported char.

I expect you put one of your value-ofs inside a text element. This works
the way you want it to:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template name="haut" match="/rhythmdb">

<xsl:text>#!/bin/bash
cd /pub/html/zicmu2/links </xsl:text>
<xsl:for-each select="entry">
<xsl:sort select="location"/>
<xsl:text>ln -s "</xsl:text>
<xsl:value-of select="substring-after(location,'file://')"/>
<xsl:text>" "</xsl:text>
<xsl:choose>
<xsl:when test="starts-with(location,'file:///pub/joe/misc')">
<xsl:value-of select="substring(location, 22)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring(location, 19)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>" </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #3
Le Tue, 27 Jan 2004 17:23:38 +0100, Patrick TJ McPhee a écrit*:
In article <pa****************************@marcfrei.org>,
StopBsod <ne**@marcfrei.org> wrote:

[...]

% So I have many unwanted carriage returns/whitspaces. (it follows the
% indentation of my .XSL...)

% I googled around and saw <xsl:text> ?

This is what you want to use. If you have non-whitespace text in a template,
then all the text in the template, including all the white space, gets
copied to the result tree. If you wrap all your non-whitespace text in
xsl:text elements, then only the text in the xsl:text elements, along with
text generated by other xsl elements, will be copied.

% Didn't work 'cause my XML file has unsupported char.

I expect you put one of your value-ofs inside a text element. This works
the way you want it to:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template name="haut" match="/rhythmdb">

<xsl:text>#!/bin/bash
cd /pub/html/zicmu2/links </xsl:text>
<xsl:for-each select="entry">
<xsl:sort select="location"/>
<xsl:text>ln -s "</xsl:text>
<xsl:value-of select="substring-after(location,'file://')"/>
<xsl:text>" "</xsl:text>
<xsl:choose>
<xsl:when test="starts-with(location,'file:///pub/joe/misc')">
<xsl:value-of select="substring(location, 22)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring(location, 19)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>" </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Thanks !

Works just perfectly. I'll study the code now ;-)

M.
Jul 20 '05 #4

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

Similar topics

1
by: Porthos | last post by:
Hello all, Is there a facet pattern that will allow for the inclusion of a newline or carriage return to occur within a tag? From the W3C schema document and from previous posts I've read that ...
6
by: Steve K | last post by:
Hi, The site I've just created, when tested on a windows PC has an unwanted white space (about 2-4 pixels high) in between two tables. I would like there to be zero space there. Here is the test...
3
by: Brian | last post by:
I have a page with content, navigation, and footer divs, in that order. The nav div has position: absolute, width 8em, on green background. The other divs have an 8em green left border, such that...
4
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to...
6
by: Lewis Edward Moten III | last post by:
I'm having some problems when debugging datasets in C#. During run-time, I arrive at a break point in my code and goto the command window. I type MyDataset.GetXML() The results are a lot of...
2
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost...
8
by: TheDude5B | last post by:
Hi, I have some data which is stored in my MySQL database as TEXT. when the data is entered in, it has some carriage returns in it, and this can be seen when querying the data using MySQL Query...
4
by: Tony Girgenti | last post by:
Hello. When i look at a web form in design view, i have the option to view the HTML. Some of the HTML code is in one long string and hard to read. Is it OK to put in carriage returns and...
3
by: Joe Stateson | last post by:
I have a template field that contains filenames that are (or can be) on a unix system. The hypen (and others) is a valid filename character in unix. When I display the name of the file I get an...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.