Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > <BR/> tag in XML content

Reply
Thread Tools

<BR/> tag in XML content

 
 
noor.rahman@gmail.com
Guest
Posts: n/a
 
      09-11-2005
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.

 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      09-11-2005
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!!!


 
Reply With Quote
 
 
 
 
Jan Roland Eriksson
Guest
Posts: n/a
 
      09-11-2005
On Sun, 11 Sep 2005 19:45:05 GMT, "Phlip" <(E-Mail Removed)> 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


 
Reply With Quote
 
noor.rahman@gmail.com
Guest
Posts: n/a
 
      09-12-2005
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?

 
Reply With Quote
 
Philippe Poulard
Guest
Posts: n/a
 
      09-12-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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()">
<xslaram 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>
<xsltherwise>
<xsl:value-of select="$text"/>
</xsltherwise>
</xsl:choose>
</xsl:template>

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      09-12-2005


(E-Mail Removed) 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/
 
Reply With Quote
 
noor.rahman@gmail.com
Guest
Posts: n/a
 
      09-12-2005
Thanks a lot guys!! Martin, your solutions with <PRE> tags worked like
a charm and did the trick.

 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      09-13-2005
(E-Mail Removed) 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error: Only Content controls are allowed directly in a content page that contains Content controls. hazz ASP .Net 6 06-09-2010 01:54 PM
Select text within a div tag by clicking on content of div tag or a button? visu Javascript 4 11-22-2006 06:25 AM
only a simple xml reader <tag:id>value</tag:id> martijn@gamecreators.nl Python 4 02-11-2006 06:44 PM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
Select text within a div tag by clicking on content of div tag? M Wells Javascript 0 10-06-2004 11:04 AM



Advertisments