473,789 Members | 2,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:styleshe et 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="locatio n"/>
ln -s "<xsl:value-of select="substri ng-after(location, 'file://')"/>"
<xsl:choose>
<xsl:when test="starts-with(location,' file:///pub/joe/misc')">
"<xsl:value-of select="substri ng(location, 22)"/>"
</xsl:when>
<xsl:otherwis e>
"<xsl:value-of select="substri ng(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 2230
>>>>> "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:styleshe et 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="locatio n"/>
<xsl:text>ln -s "</xsl:text>
<xsl:value-of select="substri ng-after(location, 'file://')"/>
<xsl:text>" "</xsl:text>
<xsl:choose>
<xsl:when test="starts-with(location,' file:///pub/joe/misc')">
<xsl:value-of select="substri ng(location, 22)"/>
</xsl:when>
<xsl:otherwis e>
<xsl:value-of select="substri ng(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.c om
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:styleshe et 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="locatio n"/>
<xsl:text>ln -s "</xsl:text>
<xsl:value-of select="substri ng-after(location, 'file://')"/>
<xsl:text>" "</xsl:text>
<xsl:choose>
<xsl:when test="starts-with(location,' file:///pub/joe/misc')">
<xsl:value-of select="substri ng(location, 22)"/>
</xsl:when>
<xsl:otherwis e>
<xsl:value-of select="substri ng(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
1800
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 should take care of this situation, however when I include that pattern (and a newline\carriage return) I still recieve an error telling me that my data is an invalid value according to its data type. When I remove the returns and new lines the...
6
3172
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 site: http://aem.cornell.edu/farmlink/ The line goes all the way across the page and it's where the NYFarmlink Logo is, the two hands shaking, it goes right through that graphic and
3
3507
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 the nav sits on that border. There is a thin red top border on footer for testing. http://www.tsmchughs.com/test/ On that page, all is as expected. However, on the long page http://www.tsmchughs.com/test/long
4
7322
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 use: 'replace carriage returns with BRs comment=Replace(comment, chr(13), "<br>") but obviously net.! The <pre> tag doesn't sem to help either as the embedded return is
6
2295
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 text with \r\n in it and is very hard to read. I have to keep scrolling left and right as the text does not wrap either. When doing the same thing in VB, it writes out actually carriage returns so that each item appears on a new line. Is there a...
2
2340
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 when pulling data from an SQL database. The thing that frustrates me the most, is that when I use Enterprise Manager, the carriage returns ARE THERE. It looks fine until I pull it out.
8
2225
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 Browser. I want to then display this text within <p> tags when requested from the database. However, the test is formatted without the carriage returns.
4
1681
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 blank lines in the HTML so that is is easier to read ? I'm not talking about changing the HTML code logic, just the readability of it.
3
4003
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 unwanted break and the text wraps at the hyphen. NavigateUrl bound to Eval("file_name","//acqlib/data/{0:c}") launches the file just fine since there is nothing wrong with the '-' on the linux system which is the acqlib server. But binding...
0
9665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6768
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.