xsl-list
[Top] [All Lists]

RE: Re: outputing tags

2003-01-05 09:34:09
It wasn't clear if you have all the answers you need, but in case you still 
need a solution to:

"Ok, then how do I do this:  I have my xml file with all the
info I need in it.  There is one element named <quote> which
contains quotes.  Some quotes need to have line break ( <br>'s
in HTML).  How do I denote a line break in the XML and then
how do I transform it?"

the answer is that XML doesn't have a special element to denote a line break. 
XSLT will happily copy any new lines you put in your source document or ones 
that you introduce in the templates, but that can be confusing (people often 
get line breaks where they weren't expecting them because of this; see 
references to  <xsl:strip-space>, <xsl:preserve-space> and the 
normalize-space() function).

Since an element like "<br />" has no "meaning" in XML, and because it is a 
perfectly well-formed element, you can put them directly into your source 
document and they will be copied into the result tree (and eventually 
serialized to your browser where "<br />" actually does have a meaning). Or you 
could introduce it in the XSLT at the appropriate points.
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Sam Carleton <sam(_at_)linux-info(_dot_)net>
Sent:     Sat, 4 Jan 2003 20:36:35 -0500
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  Re: [xsl] outputing tags

On Sat, Jan 04, 2003 at 06:43:46PM -0500, cknell(_at_)onebox(_dot_)com
wrote:
The XML sample you listed, is it the source which you are
trying to transform, or is the the output you desire to
receive? In either case, send us a sample of the other and
it will be easier to help.

Sorry about that.  The XML is the source.  I would like the
output to look something like this:

<b>This is to be displayed<br/>This is a new line<br/>And this
is on a third line</b>

Someone else posted with the obvious correct answer.  I
thought I had tried it, but guess I hadn't.
 
Rap yourself on the knuckles with a ruler! We do not output
tags, we output a node tree comprised of elements (which are
bounded by opening and closing tags).

Ok, then how do I do this:  I have my xml file with all the
info I need in it.  There is one element named <quote> which
contains quotes.  Some quotes need to have line break ( <br>'s
in HTML).  How do I denote a line break in the XML and then
how do I transform it?

Sam

-----Original Message-----
From:     Sam Carleton <sam(_at_)linux-info(_dot_)net>
Sent:     Sat, 4 Jan 2003 14:35:39 -0500
To:       XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  [xsl] outputing tags

Folks,

How do I output some tags?  The xml looks like this:
                                                                              
  
<sometag>This is to be displayed<br/>This is a new                            
  
line<br/>And this is on a thrid line</sometag>                                
  
                                                                              
  
Then I have a template like this:                                             
  
                                                                              
  
<xsl:template match="sometag">                                                
  
        <b><xsl:apply-templates/></b>                                         
  
</xsl:template>                                                               
  
                                                                              
  
How do I write a template that will output both of the                        
  
<br/>'s? so that it is displayed the right way?                               
  

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>