473,465 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Create 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 19064
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*********@gmail.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="substring-before($text, '&#xA;')"/>
<br/>
<xsl:call-template name="text">
<xsl:with-param name="text" select="substring-after($text,
'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

--
Cordialement,

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


no*********@gmail.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*********@gmail.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
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...
2
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...
6
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...
7
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...
15
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
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,...
10
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...
7
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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
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
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
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...
0
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,...
0
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
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 ...

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.