Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 21st, 2011, 04:45 PM
Registered User
 
Join Date: Jul 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT output to HTML - xml element text should look exactly as laid out in xml element

Hi There,

I have an XML file I am transforming with XSLT, output to HTML. However, I have an element that I am receiving with Text, including line feed and carriage returns (formatted). What I need to do is output that to HTML so that it looks exactly like it does when in the XML element.
I've looked in books, etc. But cannot find an answer. Just need to somehow preserve the XML element and display it as such... Html just streams all of the text.

Code:
<MESSAGE>
      <TranslationReport>
Translation Report
==================
Contains errors ? true
Contains warnings ? false
There are 9 entries in the report
Current output--
HTML Code:
Translation Report ================== Contains errors ? true Contains warnings ? false There are 9 entries in the report
Thanks,
Dj
 
Old July 21st, 2011, 04:54 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Try wrapping an HTML
Code:
<pre>
element around it.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old July 21st, 2011, 05:09 PM
Registered User
 
Join Date: Jul 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by mhkay View Post
Try wrapping an HTML
Code:
<pre>
element around it.
Thanks Michael. I had tried that and it didn't work.
Not sure if it is a table in the html. I had it in a template too. Not sure of the rules...
 
Old July 21st, 2011, 05:16 PM
Registered User
 
Join Date: Jul 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by DjGogga View Post
Thanks Michael. I had tried that and it didn't work.
Not sure if it is a table in the html. I had it in a template too. Not sure of the rules...
Looks like I typed too fast. I meant. Not sure if it is because it is within a table.
I've tried it so many ways hard to keep track of what I haven't tried. But thanks for confirming that <pre should be something that works.

Also, my xslt is v 1.0 and using Saxon 6.5.5

Cheers,
Dj
 
Old July 21st, 2011, 05:39 PM
Registered User
 
Join Date: Jul 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Michael,

Thanks so much. I was able to create a test xslt and using <pre actually worked for my XML. So, it definitely is just because of where it is in the html or something like that.
Since I am "updating" an xslt with nicely formatted html, I'll just have to play with it and maybe change the look a bit.

Cheers,
Dj





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I display xml element tags as it is in HTML gkrishna.tibco XSLT 2 November 22nd, 2010 07:42 AM
Displaying XML element in HTML attribute using XSLT bribon XSLT 3 June 16th, 2009 12:30 PM
remove duplicate text in an output html element mrame XSLT 1 June 20th, 2008 01:41 AM
XML element with delimited values and XSLT Clark Kent XSLT 15 May 7th, 2008 10:10 AM
Write XML element into textbox with XSLT tcstom XSLT 4 July 5th, 2006 04:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.