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

Home Posts Topics Members FAQ

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 2290
"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.n ag.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.n ag.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">th e 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
7854
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 "languages" files and these are describes for things on my website. Example text looks like this:
3
1982
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 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...
4
22743
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 to export the report? I tried exporting a report by using the .rtf rich-text format (the plain-text format was the only other word-processing...
2
13188
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 Lines property works, right?). But, the textbox is used for editing data previously entered into the database. Ideally, what I want is just a hard...
1
2667
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 a single line. How can I carry the text as it is entered? Thanks in advance, Burak
5
16831
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 line breaks with <br /> tags ( using the php function nl2br() ), and <br /> tags showed up in the textarea.
8
2065
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 breaks. If I open database Studio Management I see fields like this: Això és una proba pel texte sql. Els canvis de línia no es controlen bé
4
3640
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 and reaches a specific length, it terminates printing that page, prints a page number, and then begins to print the next page using the same header...
1
3080
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"> <xsl:output method="text"/> <xsl:template match="//*">
0
7882
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...
0
7808
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7914
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...
0
8181
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6564
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...
1
5683
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...
0
3809
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...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1145
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...

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.