473,881 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<BR/> tag in XML content

I have an XML file that stores data from an HTML form. I use XSL to
display the data in HTML format. The data may have newline characters.
However, XSL is not displaying the newlines properly in the browser.
I even replaced all the newlines with <BR/> tags but eventhough I see
the tags in my source, I don't get a line break in the output document.
Any help would be greatly appreciated.

Sep 11 '05 #1
7 19176
noor.rahman wrote:
I have an XML file that stores data from an HTML form. I use XSL to
display the data in HTML format. The data may have newline characters.
However, XSL is not displaying the newlines properly in the browser.
I even replaced all the newlines with <BR/> tags but eventhough I see
the tags in my source, I don't get a line break in the output document.
Any help would be greatly appreciated.


If you open the XML in a text editor, the raw text of the <br/> looks like
&lt;br/&gt; , right?

Remember that HTML payload in XML is just that - payload. XML will not see
the well-formed XML tag <br/>, and think "ahah, that's HTML, so copy it out
raw". It will see a valid XML tag, and won't emit it in the 'text' property
of the current node.

Also, depending on the actual XSL plumbing, you might need this attrocity:

&amp;lt;br/&amp;gt;

I'm not smart enough to understand if that's a bug or a feature...

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Sep 11 '05 #2
On Sun, 11 Sep 2005 19:45:05 GMT, "Phlip" <ph******@yahoo .com> wrote:
I'm not smart enough to understand if that's a bug or a feature...


I would go further to proclaim that you don't even understand the
question you commented on :)

--
Rex
Sep 11 '05 #3
thanks to both of you but i still have the problem :):) so what should
i do to fix it? is there anything/character i can put to insert a
line-break in xsl?

Sep 12 '05 #4
no*********@gma il.com wrote:
I have an XML file that stores data from an HTML form. I use XSL to
display the data in HTML format. The data may have newline characters.
However, XSL is not displaying the newlines properly in the browser.
I even replaced all the newlines with <BR/> tags but eventhough I see
the tags in my source, I don't get a line break in the output document.
Any help would be greatly appreciated.


&#xA; is certainly what you're looking for :

<xsl:template name="text" match="text()">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="contains( $text, '&#xA;')">
<xsl:value-of select="substri ng-before($text, '&#xA;')"/>
<br/>
<xsl:call-template name="text">
<xsl:with-param name="text" select="substri ng-after($text,
'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwis e>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
Sep 12 '05 #5


no*********@gma il.com wrote:
I have an XML file that stores data from an HTML form. I use XSL to
display the data in HTML format. The data may have newline characters.
However, XSL is not displaying the newlines properly in the browser.
XSL is not displaying anything in the browser, the browser displays the
HTML your XSL produced and thus if you have any HTML display issue you
need to look into how HTML displays white space like newline characters.

And HTML's normal rendering of white space is white space collapsing
meaning whether you author e.g. a paragraph as

<p>a
b
c
d
</p>

or

<p>a b c d</p>

the normal rendering will collpase several white space characters in the
source to one inter-word space so rendering might be alike

a b c d

So the solution is to understand how HTML works and if the whitespace in
an element is to matter then to use for instance the <pre> element e.g.

<pre>a
b
c
d
</pre>

I even replaced all the newlines with <BR/> tags but eventhough I see
the tags in my source, I don't get a line break in the output document.


We need to see a minimal XSLT stylesheet and minimal XML input to make
suggestions on what you might be doing wrong in terms of XSLT to have
<br> elements in HTML output generated with XSLT.

Or look first at Philippe's answer to find a template that transforms
text with line breaks into markup with <br/> elements.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 12 '05 #6
Thanks a lot guys!! Martin, your solutions with <PRE> tags worked like
a charm and did the trick.

Sep 12 '05 #7
no*********@gma il.com wrote:
thanks to both of you but i still have the problem :):) so what should
i do to fix it? is there anything/character i can put to insert a
line-break in xsl?


Output a real <br> element to HTML.

///Peter

Sep 13 '05 #8

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

Similar topics

4
7868
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:
2
10573
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script type="text/javascript"> <!]> </script> <script type="text/javascript"
6
12164
by: Lasse | last post by:
I have done this simple function, it seems to work as intended, to solve a problem i have had for a while. I couldnt find any sample around that was working for me. I would like to test it with you and see if there are any improvments that i should make ;-) It should be fast and if possible compatible with todays modern browser-standards. It should be activated by the onload-event. This is my code, free for all to use:
7
2756
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no tags will remain making the page safe (I have to convert the linefeeds to <BR>s because the Server.EncodeHTML does not do that it seems). The problem is that users can use a special tag when editing the top to specify an area of the tip that will...
15
2757
by: tshad | last post by:
How do I go about this? I used to know this, but can't find VB.net replace that does this. Something like string.replace("<br>",NL) Thanks,
3
3400
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt, &gt ,&ltCompany&gt to display '<', '>' and '<Company>' respectively. But is there any freeware code available which could implement the above functionality without having to use &gt,&lt and such stuff???
10
3213
by: Summercoolness | last post by:
so i am starting to use more of <br /and <div style="clear: both" / which is the XHTML style... now, won't those actually confuse the old browsers? for example, will the old browser treat the "div" as not closing, and so everything after the div will be treated as part of that div?
7
3636
by: Nathan Sokalski | last post by:
Something that I recently noticed in IE6 (I don't know whether it is true for other browsers or versions of IE) is that it renders <br/and <br></br> differently. With the <br/version, which is what most people use when they write static code (some people use <br>, but with xhtml you are required to close all tags), IE6 simply breaks to the next line like it is supposed to. However, with <br></br>, which is what is sometimes generated by...
0
9776
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10716
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10812
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
10400
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9552
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
7953
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
7108
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
5976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3223
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.