aspose file tools*
The moose likes XML and Related Technologies and the fly likes Displaying characters in multiplelines using xml and xsl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Displaying characters in multiplelines using xml and xsl" Watch "Displaying characters in multiplelines using xml and xsl" New topic
Author

Displaying characters in multiplelines using xml and xsl

N Naresh
Ranch Hand

Joined: Nov 04, 2008
Posts: 66
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
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
HTML disregards newline or carriage return characters. You'll need to replace them by <br/> tags.


Ping & DNS - updated with new look and Ping home screen widget
N Naresh
Ranch Hand

Joined: Nov 04, 2008
Posts: 66
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
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
"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

Joined: Nov 04, 2008
Posts: 66
what is this EXSLT function???
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
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

Joined: Nov 04, 2008
Posts: 66
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

Joined: Nov 04, 2008
Posts: 66
I need help in resolving this issue
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

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

Joined: Nov 04, 2008
Posts: 66
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

Joined: Nov 04, 2008
Posts: 66
please help me to solve this problem
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Did you read the FAQ entry Paul pointed you to?
N Naresh
Ranch Hand

Joined: Nov 04, 2008
Posts: 66
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
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
That FAQ entry does contain an example. What do you not understand about it?
N Naresh
Ranch Hand

Joined: Nov 04, 2008
Posts: 66
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
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
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
 
subject: Displaying characters in multiplelines using xml and xsl
 
Similar Threads
Need a Text Editor
Displaying xml data using xsl
handling multiple languages using XSL
Displaying Japanese characters using XSL
How to convert XML file to an HTML file using XSLT