|
|
 |
| 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 computer programmers 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 programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
|
 |

February 13th, 2007, 05:04 PM
|
|
Registered User
|
|
Join Date: Jan 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

February 13th, 2007, 05:24 PM
|
|
Registered User
|
|
Join Date: Jan 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Problem solved:
Found this template and works fine...
<xsl:template name="strip-tags">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="contains($text, '<')">
<xsl:value-of select="substring-before($text, '<')"/>
<xsl:call-template name="strip-tags">
<xsl:with-param name="text" select="substring-after($text, '>')"/>
</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>
|

February 13th, 2007, 06:55 PM
|
 |
Wrox Author
Points: 13,389, Level: 50 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,025
Thanks: 0
Thanked 114 Times in 112 Posts
|
|
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |