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

Line breaks in text mode for XSLT

I'm finding it difficult to determine when/where XSLT generates line breaks
when generating a text file <xsl:output method="text"
media-type="text/plain"/>

And... I'm getting thoroughly different results from whatever XSLT processor
comes with Altova XMLSpy than I'm getting from Xalan.

Can anyone give me a small tutorial on this topic?

Thanks,

Dave Blickstein

Jul 20 '05 #1
5 2274
"David Blickstein" <db@hp.com> writes:
I'm finding it difficult to determine when/where XSLT generates line breaks
when generating a text file <xsl:output method="text"
media-type="text/plain"/
It never breaks lines at all, line ends will just be inserted at places
that you insert them explitly in your code (or copy them from teh
source)



And... I'm getting thoroughly different results from whatever XSLT processor
comes with Altova XMLSpy than I'm getting from Xalan.
Possibly xmlspy is using the msxml parser which will throw away any
white space nodes on input (which is a documented non-conformance)
so if you are copying nodes from the source to the result it's quite
likely that you lose white space if msxml is being used.
Can anyone give me a small tutorial on this topic?

Thanks,

Dave Blickstein


David
Jul 20 '05 #2
"David Carlisle" <da****@nag.co.uk> wrote in message
news:yg*************@penguin.nag.co.uk...> Possibly xmlspy is using the
msxml parser which will throw away any
white space nodes on input (which is a documented non-conformance)
so if you are copying nodes from the source to the result it's quite
likely that you lose white space if msxml is being used.


Thank you SO MUCH for taking the time to reply.

You were right. When I added an xsl:strip-space tag, the results were
correct with both XMLSpy and Xalan.

I'll confessed I'm at a loss to explain WHY that corrected it because
essentially ALL the content in this section is drawn from attribute values
(which I know don't contain any newline characters) rather than element
content but... I'm just happy it worked.

Thanks again,

Dave Blickstein
Jul 20 '05 #3
ALL the content in this section is drawn from attribute values


I guess you just proved that statement false:-)

Most likey you have

<x>
<y foo="1"/>
<y foo="2"/>
<y foo="3"/>
</x>
And have a template
<xsl:template match="y">
<xsl:value-of select="@foo"/>
</xsl:template>
but the reason that the template for y gets called is that the default
template for <x> is doing <xsl:apply-templates/> which is
<xsl:apply-templates select="node()"/>
so by default applies templates to (and copies) the white space nodes
used to indent the input.

David
Jul 20 '05 #4
That explains it. Interestingly, in this particular stylesheet there are no
apply-template tags so there was nothing to "look for" along those lines,
but obviously the default actions kicked in.

Thank you so much again. It used to be a total pain for me to get the
stylesheets to do what I wanted them to do, since adding the strip-space
tag, everything now happens as I expect and I'm making rapid progress.

Thanks again,

db

"David Carlisle" <da****@nag.co.uk> wrote in message
news:yg*************@penguin.nag.co.uk...
ALL the content in this section is drawn from attribute values


I guess you just proved that statement false:-)

Most likey you have

<x>
<y foo="1"/>
<y foo="2"/>
<y foo="3"/>
</x>
And have a template
<xsl:template match="y">
<xsl:value-of select="@foo"/>
</xsl:template>
but the reason that the template for y gets called is that the default
template for <x> is doing <xsl:apply-templates/> which is
<xsl:apply-templates select="node()"/>
so by default applies templates to (and copies) the white space nodes
used to indent the input.

David

Jul 20 '05 #5
David Blickstein wrote:
That explains it. Interestingly, in this particular stylesheet there are
no apply-template tags so there was nothing to "look for" along those
lines, but obviously the default actions kicked in.

Thank you so much again. It used to be a total pain for me to get the
stylesheets to do what I wanted them to do, since adding the strip-space
tag, everything now happens as I expect and I'm making rapid progress.


If your application uses mixed content, be careful that strip-space doesn't
bite you in the butt: there is an unpleasant side-effect that the space
between two adjacent elements will be removed even in mixed content, even
using a Schema or DTD where the XSLT application ought to know better, eg

<para>Remove <part no="abc123">the nut</part> <emph>anti-clockwise</emph>...

will give you "Remove the nutanti-clockwise". This isn't a bug: it's just
rather sloppy design -- so strip-space really does mean what it says,
and has been implemented for use in "data" XML rather than "document"
applications which use mixed content models where white-space nodes should
be normalized to a single space token, not normalized out of existence.

///Peter
--
sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
&;top"
Jul 20 '05 #6

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

Similar topics

4
by: fis | last post by:
Hi all, I've problem because there are needed break lines in my texts on the web site but i can't do it :( My pipeline looks like: XMS -> I18N -> XSLT -> HTML I have lot of texts in my...
3
by: bjam | last post by:
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...
4
by: intl04 | last post by:
I have a memo field that is included in some Access reports I created. Is there some way for the memo field to display nicely formatted text, with line breaks between paragraphs? Or is it necessary...
2
by: Mike | last post by:
I need my textbox to work more smoothly with respect to line breaks. When I have data pulled from the database into a textbox there are hard line breaks at the end of each line (by definition how...
1
by: buran | last post by:
Dear ASP.NET Programmers, I am carrying the input of a textbox via querystring. When I put the value of querstring in a label control, the line breaks are removed. The whole text is displayed as...
5
by: joelbyrd | last post by:
Didn't know exactly where to post this, but: How do I get line breaks in a textarea? I'm pulling text from a database, and this text definately has line breaks in it, because I replaced all the...
8
by: Juan Puebla | last post by:
Hi, I have an sql database with some text (nvarchar) fields. The problem is that if I get those fields with a datareader (dr.getstring(0)) an then I save text in a txt file I loose all the line...
4
by: Ed Jay | last post by:
I generate a DHTML page (a medical report) with dynamically generated text based on user input (answers to questions). The page length changes dynamically. I desire that when the page is printed...
1
by: Arndt Jonasson | last post by:
I have this xslt transform ex.xsl and an instance document ex.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.