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 27th, 2009, 06:31 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 How to remove Attribute Space

Hi,

We would like to remove the unwanted space which is generated after the locator attribute.

Input:
Code:
<index.level level="3"><name>Administration proposal to increase tax rate by 0.3 percent opposed, "decoupling" proposal accepted, text</name> <locator punct.before=" ">26:A-5</locator> <locator punct.before=", ">D-1</locator>
</index.level>
Xslt:
Code:
<!-- For Index-Level-->
<xsl:template match="index.level">
<xsl:choose>
<xsl:when test="@level='3'">
		<xsl:element name="p"><xsl:attribute name="style">padding-left: 4em;</xsl:attribute> 
			<strong><xsl:text>–</xsl:text><font color ="DarkViolet">
			<xsl:apply-templates/></font></strong>
		</xsl:element>
		</xsl:when>
		<xsl:when test="@level='4'">
		<xsl:element name="p"><xsl:attribute name="style">padding-left: 6em;</xsl:attribute><strong>––<font color ="MediumBlue">
			<xsl:apply-templates/></font></strong>            
		</xsl:element>
		</xsl:when>
        </xsl:choose>
    </xsl:template>

<!--For Locator-->
<xsl:template match="locator[@punct.before]">
        <xsl:variable name="punct"><xsl:value-of select="@punct.before"/></xsl:variable><span style = "color:DarkSlateGray;"><span style = "color:DeepPink;"><xsl:value-of select="$punct"/></span><xsl:apply-templates/></span>
    </xsl:template>

Output:
Code:
–Administration proposal to increase tax rate by 0.3 percent opposed, "decoupling" proposal accepted, text 26:A-5 , D-1

In the above output, space comma(Red Color) should be comma i.e., 26:A-5, D-1

Please advice for deleting unwanted space before the locator..


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

Insert
Code:
<xsl:strip-space elements="index.level"/>
in your stylesheet (as a child of the xsl:stylesheet element).
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old November 27th, 2009, 07:41 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 RE: How to remove Attribute Space[Reply 1]

As per your reply, if we code as
Code:
<xsl:strip-space elements="index.level"/>
it will strip spaces for the index.level element including all the child elements.

But we would like to use the strip space for the particular element "locator" so that we modify the code as
Code:
<xsl:strip-space elements="locator"/>
but in the output no differences was found.

Please clarify where we're struck.

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

Well your locator elements do not contain any white space that could be stripped so I am not sure why you think attempting to strip space from those elements would change anything.
The index.level elements has white space between its child elements and you do not seem to want to output that white space so that is why I suggested to apply strip-space to that element.
If you want to preserve certain white space and omit other white space then you need to explain exactly what determines which white space to preserve and which to omit.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
rangeshram (November 27th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove unwanted attribute thava XSLT 9 March 12th, 2009 05:51 AM
How to remove extra space from PSV dved XSLT 2 February 18th, 2009 10:52 AM
remove commas and space in a string kumiko Classic ASP Basics 1 January 10th, 2008 11:42 PM
Remove the unwanted space at end of the string gmbalaa General .NET 2 August 21st, 2007 11:35 PM
Remove Space from table records mateenmohd SQL Server 2000 1 July 20th, 2003 06:55 AM





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