Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| 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 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 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

 
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>



 
Old February 13th, 2007, 06:55 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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
 
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
 
Old June 19th, 2012, 08:34 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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




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





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