Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 13th, 2007, 05:04 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default strip html tags with xslt

I am busy with a website where customers can edit there profile. They can also use some kind of editor which produces html tags that will be wrapped around the text.

The xml looks something like this:

<Profile>
<p>This is a <b>profile</b> text blablalbla</p><br/>
</Profile>

Now I am creating some kind of master page with links to detail pages. On the detailpages the html has to be output as html code (using disable output-escaping).

On the masterpage I just want this as output:
"This is a profile text blablalbla"

So all the html tags must be ignored or stripped out.


Is this possible with xslt?

Thanks in advance,

M. Smit

Reply With Quote
  #2 (permalink)  
Old February 13th, 2007, 05:24 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Problem solved:

Found this template and works fine...

<xsl:template name="strip-tags">
    <xsl:param name="text"/>
    <xsl:choose>
        <xsl:when test="contains($text, '&lt;')">
            <xsl:value-of select="substring-before($text, '&lt;')"/>
            <xsl:call-template name="strip-tags">
                    <xsl:with-param name="text" select="substring-after($text, '&gt;')"/>
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$text"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

Use it this way:

<xsl:call-template name="strip-tags">
    <xsl:with-param name="text" select="Profile"/>
</xsl:call-template>



Reply With Quote
  #3 (permalink)  
Old February 13th, 2007, 06:55 PM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

Sure, just do

<xsl:value-of select="Profile"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #4 (permalink)  
Old June 19th, 2012, 07:23 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default I want remove <p> tags from sitecore rich text editor

I want remove <p> tags from sitecore rich text editor in xslt.

Please help on this.

Thanks in advance.


-Mani
Reply With Quote
  #5 (permalink)  
Old June 19th, 2012, 08:34 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

If this is an XSLT question, please show us a sample input document and the output you want from it. Please also explain what you have tried and where you got stuck; this helps us to know how much explanation we need to give in reply. Please also don't assume that anyone on this forum knows anything about the sitecore rich text editor. Finally, please start a new question on a new thread, rather than replying to a thread that is more than five years old.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
add HTML tags via XSLT chopswil2 XSLT 3 November 5th, 2007 09:30 AM
XSLT help : Interpretting HTML tags from XML kunal_kishan XSLT 1 June 26th, 2006 05:37 AM
Strip HTML with ASP Question ryanpatrick Classic ASP Professional 1 January 17th, 2005 08:15 AM
strip html tags & PHP trangd Beginning PHP 6 October 21st, 2003 10:28 AM
PHP & Strip tags trangd Pro PHP 1 October 20th, 2003 12:23 PM



All times are GMT -4. The time now is 11:33 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.