Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 06-06-2009
Member
 
Join Date: Feb 2009
Posts: 66
Replace <br>,</br> tags with <br/> using XSL

hie friends,

I want to change the HTML tags <br> and </br> which are responsible to break the paragraph or starting a sentence from the new line, with something like <br/> using XSL. Is it possible to replace these break tags (<br> & </br>) with <br/>. How can I do the same ?
any ideas....
Reply With Quote
  #2  
Old 06-06-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Replace <br>,</br> tags with <br/> using XSL

Check this -

Code:
<xsl:template match="text()">
   <xsl:call-template name="break">
</xsl:template>

<xsl:template name="break">
   <xsl:param name="text" select="."/>
   <xsl:choose>
   <xsl:when test="contains($text, '&#xa;')">
      <xsl:value-of select="substring-before($text, '&#xa;')"/>
      <br/>
      <xsl:call-template name="break">
          <xsl:with-param name="text" select="substring-after($text,
'&#xa;')"/>
      </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
	<xsl:value-of select="$text"/>
   </xsl:otherwise>
   </xsl:choose>
</xsl:template>
Reply With Quote
  #3  
Old 06-06-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Replace <br>,</br> tags with <br/> using XSL

In my XML script, I have tried this:

<xsl:template match="myelem">
<div>
<xsl:value-of select="translate(., '\n', '<br />')" />
</div>
</xsl:template>

But I get the folllowing error:

The character '<' cannot be used in an attribute value.
Error processing resource 'http://localhost/test.xml'...
<xsl:value-of select="translate(., '\n', '<br />')" />
Reply With Quote
  #4  
Old 06-06-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: Replace <br>,</br> tags with <br/> using XSL

You can try this - <xsl:value-of select="translate(., '\n', '&lt;br /&gt;')" />
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Replace <br>,</br> tags with <br/> using XSL"
Thread Thread Starter Forum Replies Last Post
How to add tags to PDF and txt files Vincent D Windows Software 5 15-04-2011 10:17 AM
Javascript - replace HTML tags with spaces Jensen Ackles Software Development 6 13-05-2010 12:10 PM
What are an ID3 tags in PHP? Jacques25 Software Development 4 28-02-2010 03:36 AM
<br /> Tags are being ignored by IE7 Carey Software Development 5 30-12-2009 10:58 PM
Tags (or tags) PHP Gyan Guru Guides & Tutorials 2 22-12-2008 01:04 PM


All times are GMT +5.5. The time now is 06:35 AM.