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 27th, 2006, 03:30 AM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default to append <br> in XSLT

Hi
i am displaying a string in a table cell ... here i am formatting the string so that it will display in two lines in the table cell
i am appending '&lt;br&gt;' in the middle of the string but it is becoming 'string<br>string' in html
i want it to show up in two lines
please help me out
thank you
 
Old July 27th, 2006, 03:46 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT creates HTML in the form of a result tree; the processor then looks after the job of serializing this as textual HTML (in fact, some browsers do the rendering directing from the tree, never creating the textual HTML as an intermediate form).

So you need to write a BR element, not the four characters "<BR>". The way you do that is to write <BR/> in your stylesheet.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 28th, 2006, 11:11 AM
Registered User
 
Join Date: Jul 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am having the same issue as dharus, and while I understand you want to write <BR/> in the stylesheet I am having issues getting it written. My starting point is text from an XML document that can have zero or more newlines. If present, the newlines will be in random locations.

My best solution at this point is a javascript function that finds and replaces each newline in the string. The find and replace works, but the output is always in the form '&lt;br&gt;'. The function is one I found on the Web and is enclosed in a CDATA section which I don't believe is what I want, but I get exceptions from the .NET parser when I try to remove the CDATA section.

Any thoughts?

 
Old July 28th, 2006, 04:20 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I can't tell you what's wrong with your code if you don't show me your code, and in any case the interface to external languages like Javascript is very processor-dependent. I imagine your javascript was returning the string of four characters "<br>" rather than returning an element node; although it would be legal for a processor to interpret that as markup (as I say, it's all processor-dependent) I think it's more likely to be interpreted as text.

A quick google gives you working XSLT 1.0 code here:

http://www.xslt.com/html/xsl-list/2002-03/msg01000.html

It's much easier in 2.0, of course.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 1st, 2006, 09:52 AM
Registered User
 
Join Date: Jul 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the link. My searches did not find this information. I dumped the javascript for the template and my transform works.

Yes, I need to learn 2.0. Time to get Saxon for .NET and buy your book...

Regards,

Rich






Similar Threads
Thread Thread Starter Forum Replies Last Post
text-align:justify; and <BR> anshul HTML Code Clinic 23 June 18th, 2018 03:04 AM
Replace "<enter>" with "<br>" Varg_88 Classic ASP Basics 5 February 14th, 2011 12:33 PM
<br/> becomes <br></br> Kabe XSLT 1 July 6th, 2007 07:42 AM
Replacing Garriage Returns with <br /> rit01 ASP.NET 2.0 Basics 7 March 21st, 2006 03:33 AM
Replace vbcrlf with <br> using C# kgriffin ASP.NET 1.0 and 1.1 Basics 2 May 4th, 2005 09:29 AM





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