473,499 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

spacing in XSLT, return char after each line? / last record separator removal

Hi,

I am hoping someone can help with this I am assuming it is pretty
basic but I don't see anything that jumps out at me at how to do this.
Is there a way to have all the items output from the style sheet appear
as a single line with no return chars?? When executing the following
style sheet, how can I concatenate the values together in a single
line, in this case a single line would be how the browser displays
this, but I want the general text output to be a single line as well.
Basically is there a way to have all these lines concatenated together
when being outputted by the style sheetinstead of having a return
character after each line? Also, is there a way to have the xslt know
to not produce the last pipe on the line??? Maybe some type of
following-sibling??
Thanks in advance for your help. I appreciate it.

Desired Ouptput (note last data element does not have pipe)
================

<html xmlns:rep="http://localhost:7001/reporting"><body><table
border="0"><tr><td>11006732.908899993|</td><td>7941634.67709|</td><td>3065098.23181004|</td><td>3065098.23181004|</td><td>11006732.908899993</td></tr></table></body></html>
The output I am getting
( returns in output and last data element does have pipe)
=======================

$ test_XSLT.pl ( this is just my perl code that translates XSLT)

<html xmlns:rep="http://localhost:7001/reporting"><body><table
border="0"><tr>
<td>11006732.908899993|</td>
<td>7941634.67709|</td>
<td>3065098.23181004|</td>
<td>3065098.23181004|</td>
<td>11006732.908899993|</td>
</tr></table></body></html>

END OF TEST ./test_XSLT.pl
Style sheet below
==================

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rep="http://localhost:7001/reporting">

<xsl:template match="/">

<html>
<body>
<table border="0">
<tr>

<xsl:apply-templates
select="/rep:FrontPage/rep:frontPageSection/rep:sectionLine"/>

</tr>
</table>

</body>
</html>

</xsl:template>

<xsl:template
match="/rep:FrontPage/rep:frontPageSection/rep:sectionLine">
<xsl:apply-templates select="rep:lineName[starts-with(text(),'MARGIN
EQUITY')]"/>
<xsl:apply-templates select="rep:lineName[starts-with(text(),'HOUSE
REQUIREMENTS')]"/>
<xsl:apply-templates select="rep:lineName[starts-with(text(),'HOUSE
MARGIN EXCESS/DEFICIT')]"/>
<xsl:apply-templates select="rep:lineName[starts-with(text(),'CASH
AVAILABLE')]"/>
</xsl:template>

<!-- MARGIN EQUITY -->

<xsl:template match="rep:lineName[starts-with(text(),'MARGIN
EQUITY')]">

<td> <xsl:value-of select="../rep:amountAtDate[text()]"/>
<xsl:text>|</xsl:text></td>

</xsl:template>

<!-- HOUSE REQUIREMENTS-->

<xsl:template match="rep:lineName[starts-with(text(),'HOUSE
REQUIREMENTS')]">

<td> <xsl:value-of select="../rep:amountAtDate[text()]"/>
<xsl:text>|</xsl:text></td>

</xsl:template>
<!-- HOUSE MARGIN EXCESS DEFICIT -->

<xsl:template match="rep:lineName[starts-with(text(),'HOUSE MARGIN
EXCESS/DEFICIT')]">

<td> <xsl:value-of select="../rep:amountAtDate[text()]"/>
<xsl:text>|</xsl:text></td>

</xsl:template>

<!-- CASH AVAILABLE -->

<xsl:template match="rep:lineName[starts-with(text(),'CASH
AVAILABLE')]">

<td> <xsl:value-of select="../rep:amountAtDate[text()]"/>
<xsl:text>|</xsl:text></td>

</xsl:template>

</xsl:stylesheet>
Data Snippet
=============

<rep:FrontPage xmlns:rep="http://localhost:7001/reporting">
<rep:dateGenerated q="1">Fri Apr 1 14:49:29 2005</rep:dateGenerated>
<rep:dateGeneratedTimeZone q="1">Eastern Standard Time
(US/Eastern)</rep:dateGeneratedTimeZone>

<rep:date q="1">2005-03-31-05:00</rep:date>
<rep:previousDate q="1">2005-03-30-05:00</rep:previousDate>
<rep:frontPageSection>
<rep:sectionName q="1">GLOBAL MARGIN ROLL-UP (USD)</rep:sectionName>
<rep:sectionLine>
<rep:lineName q="1">MARGIN EQUITY</rep:lineName>
<rep:amountAtDate q="0">11006732.908899993</rep:amountAtDate>
<rep:amountAtPreviousDate
q="0">-539473.0115977892</rep:amountAtPreviousDate>
</rep:sectionLine>
<rep:sectionLine>
<rep:lineName q="1">HOUSE REQUIREMENTS</rep:lineName>
<rep:amountAtDate q="0">7941634.67709</rep:amountAtDate>
<rep:amountAtPreviousDate q="0">0</rep:amountAtPreviousDate>
</rep:sectionLine>
<rep:sectionLine>
<rep:lineName q="1">HOUSE MARGIN EXCESS/DEFICIT</rep:lineName>
<rep:amountAtDate q="0">3065098.23181004</rep:amountAtDate>
<rep:amountAtPreviousDate
q="0">-539473.011597789</rep:amountAtPreviousDate>
</rep:sectionLine>
<rep:sectionLine>
<rep:lineName q="1">CASH AVAILABLE</rep:lineName>
<rep:amountAtDate q="0">3065098.23181004</rep:amountAtDate>
<rep:amountAtPreviousDate
q="0">-539473.011597789</rep:amountAtPreviousDate>
</rep:sectionLine>
</rep:frontPageSection>
<rep:frontPageSection>
<rep:sectionName q="1">US COMBINED MARGIN PB </rep:sectionName>
<rep:sectionLine>
<rep:lineName q="1">LONG MARKET VALUE</rep:lineName>
<rep:amountAtDate q="0">91617178.1389</rep:amountAtDate>
<rep:amountAtPreviousDate q="0">0</rep:amountAtPreviousDate>
</rep:sectionLine>
<rep:sectionLine>
<rep:lineName q="1">SHORT MARKET VALUE</rep:lineName>
<rep:amountAtDate q="0">-5365772.36</rep:amountAtDate>
<rep:amountAtPreviousDate q="0">0</rep:amountAtPreviousDate>
</rep:sectionLine>
<rep:sectionLine>
<rep:lineName q="1">CASH BALANCE CR (DR)</rep:lineName>
<rep:amountAtDate q="0">-75857105.73</rep:amountAtDate>
<rep:amountAtPreviousDate q="0">0</rep:amountAtPreviousDate>
</rep:sectionLine>
<rep:sectionLine>
<rep:lineName q="1">BOND ACCRUED INTEREST</rep:lineName>
<rep:amountAtDate q="0">612432.86</rep:amountAtDate>
<rep:amountAtPreviousDate q="0">0</rep:amountAtPreviousDate>
</rep:sectionLine>
<rep:sectionLine>
<rep:lineName q="1">REG U EXCESS/DEFICIT</rep:lineName>
</rep:sectionLine>
<rep:sectionLine>
<rep:lineName q="1">MARGIN EQUITY</rep:lineName>
<rep:amountAtDate q="0">11006732.908899993</rep:amountAtDate>
<rep:amountAtPreviousDate q="0">0</rep:amountAtPreviousDate>
</rep:sectionLine>
</rep:frontPageSection>

Jul 20 '05 #1
3 1975
"bjam" <bs****@yahoo.com> writes:
Hi,

I am hoping someone can help with this I am assuming it is pretty
basic but I don't see anything that jumps out at me at how to do this.
Is there a way to have all the items output from the style sheet appear
as a single line with no return chars??
XSLT never adds any characters on its own. any newlines in the output
are copied from the source or the stylesheet.
It isn't clear from your question wheter you are concerned about
newlines in the generated html (which render as a space in a browser) or
newlines in the rendered result which come from markup or from a <pre>
section.
When executing the following
style sheet, how can I concatenate the values together in a single
line, in this case a single line would be how the browser displays
this, but I want the general text output to be a single line as well.
Basically is there a way to have all these lines concatenated together
when being outputted by the style sheetinstead of having a return
character after each line? Also, is there a way to have the xslt know
to not produce the last pipe on the line??? Maybe some type of
following-sibling??

yes wrap it in
<xsl:if test="position()!=last()">
or
<xsl:if test="following-sibling::*">
or whatever you need.
Jul 20 '05 #2
David,

Hi I was interested in new lines in the generated output itself (the
actual html with tags that is showing not what the browser would
render), because ultimately I would not be using the html tags and just
removing them to have the text itself be a single line. Any ideas?
Also for the last character instead of the pipe it would be great to
acutally put a newline character in data string. Therefore ultimately
the data ( once I strip out the html tags would look as follows )
11006732.908899993|7941634.67709|3065098.23181004| 3065098.23181004|11006732.908899993
(note newline would go here instead of pipe)

Jul 20 '05 #3
David,

Hi, thanks again for the positon()!=last() this seems to have worked
even though I had to play with it a bit. Also, setting the following
line seemed to fix a lot of the tagging issues I was experiencing

<xsl:output method = "text" />

Jul 20 '05 #4

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

Similar topics

1
1896
by: Doug Farrell | last post by:
Hi all, I'm trying to use the 4Suite xml/xsl tools to transform some XML data into HTML. I'm using some examples from the O'Reilly book "Python and XML" and things are blowing up. Here is the...
3
1622
by: Mike Whittemore | last post by:
I am trying to convert an HTML table into a list of name-value pairs, one pair per field in the table. I believe my XSLT is correct, but I've tried both Xalan and Saxon, which both fail with...
2
1504
by: Ding Lei | last post by:
Hello folks, I am using xml for a newsletter, along with a xsl file to display it in a browser. In the xml file, a newline, tab or whitespace character all causes exactly one spacing between two...
4
1817
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
12
2872
by: das | last post by:
Hello all, I am using .NET XSLT to transform an XML into another XML file. All this is fine with small files, but when tested with big files (30MB) it is taking between 1hr-2hrs to just transform...
10
2295
by: olivier.scalbert | last post by:
Hello, the following constraints: source: <Source> <Item>AAA</Item> <Item>BBBBBBBBBBB</Item> <Item>CCCCCCCCC</Item> <Item>DDDDDDDDDDDDDDD</Item>
3
9535
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the...
1
5659
by: Sandeep Singh | last post by:
Hi, How to do group by in XSLT ? I tried on the following codes: <files> <file name="swablr.eps" size="4313" project="mars"/> <file name="batboy.wks" size="424" ...
0
7130
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
7171
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
7220
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...
1
6893
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...
0
5468
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,...
1
4918
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...
0
4599
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...
0
1427
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 ...
0
295
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...

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.