Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 November 23rd, 2009, 07:42 AM
Authorized User
 
Join Date: May 2008
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rangeshram
Default XLST Replace

Hi All,

I would like to know how to replace the attribute with '\'(BackwardSlash) with '_'(Underscore). Since we have to assign the path for href purpose.

I am extracting the ref.id attribute with the following xslt:


Code:
 
<xsl:template match="index.level">
<a><xsl:attribute name="name"><xsl:apply-templates select="@ref.id"/></xsl:attribute></a>
 
 
<xsl:template match="xref.index"><a><xsl:attribute name="href"><xsl:text>#</xsl:text>
<xsl:apply-templates select="@ref"/></xsl:attribute><xsl:apply-templates/></a></xsl:template>
Input:
Code:
 
<index.level ref.id="Exemp_254\AFL-CIO"><name>AFL-CIO</name>
....
<xref.index ref="Exemp_254\AFL-CIO">See AFL-CIO</xref.index>
output required:
Code:
 
<a name="Exemp_254_AFL-CIO">AFL-CIO
 
<a href="Exemp_254_AFL-CIO">See AFL-CIO
Please provide me solution for replace.

Thanks
 
Old November 23rd, 2009, 07:50 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Use translate e.g.
Code:
<xsl:template match="index.level">
  <a name="{translate(@ref.id, '\', '_')}">...</a>
</xsl:template>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Substring function in xlst 1.0 troubeshooting fixit XSLT 1 November 18th, 2009 01:30 PM
how to use pagination in xsl or xlst vijayanmsc XSLT 1 June 6th, 2006 06:07 AM
XLST Multiple Foreach deepsweech XSLT 3 June 20th, 2005 09:46 AM
XLST transformNode problem beyondtron Classic ASP XML 0 February 4th, 2004 04:52 PM
XLST vs Sever Controls skin XSLT 3 July 11th, 2003 01:29 PM





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