This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying characters in multiplelines using xml and xsl

 
N Naresh
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am using xml and xsl to display characters in multiple lines
the text content is like this "mm\r\nkk\r\njj" but i am unable to display this characters in multiple lines like below in the browser

mm
kk
jj

actually in our java class we are creating textnode for the above text using document object like doc.createTextnode("mm\r\nkk\r\njj")
in xsl we are reading this data as <xsl:value-of select="text()"/>

could anybody suggest me how to display characters in multiple lines using xsl.


Naresh.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML disregards newline or carriage return characters. You'll need to replace them by <br/> tags.
 
N Naresh
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there is anyway to display characters in multiple lines without hardcoding with <br/> tag please help me it is very urgent for me.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"br" tags are to HTML what \r and/or \n are to plain text. What works for one won't work for the other.

Maybe an EXSLT extension function that performs the replacement would work?
 
N Naresh
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is this EXSLT function???
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See http://www.xml.com/pub/a/2005/01/05/tr-xml.html

Xalan -one of the major XSLT processors written in Java- supports EXSLT functions written in Java: http://xml.apache.org/xalan-j/extensions.html
 
N Naresh
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not able to understand with links you have given it would be better for me if you can give small example which might solve my problem.
 
N Naresh
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help in resolving this issue
 
Paul Clapham
Sheriff
Pie
Posts: 20188
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't quite tell what your question is. It seems that you are producing HTML, but you didn't say that. And then it seems that you want the newline characters to be converted to
elements, so that they appear as newlines in the browser. Is that correct?

But that's one of the commonest questions about XSLT. It has its own entry in the XSLT FAQ, here:

http://www.dpawson.co.uk/xsl/sect2/N8321.html#d12587e366
 
N Naresh
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how exactly we can make changes to java code while generating xml so that xsl will recognize to display text content with \r\n ex:kk\r\njj\r\nhh will display in multiple lines in browser(html).
 
N Naresh
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me to solve this problem
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the FAQ entry Paul pointed you to?
 
N Naresh
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i went through it but it is not clear for me it would be better if there is an example to solve this problem
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That FAQ entry does contain an example. What do you not understand about it?
 
N Naresh
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not understanding what i need to give in the place $cr, how i can mention to xsl to convert \r\n to <br/>?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you run the example and see what it does? Maybe then things will become clearer.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic