[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xsl:strip-space does not work?

Subject: xsl:strip-space does not work?
From: Mark Nahabedian <naha@xxxxxxxxxx>
Date: Fri, 16 Nov 2001 18:24:21 -0500
normalize space strip space
Nisheet Verma writes:
 > I am using a  xml file which looks like, the following ( I have removed
 > insignificant text to improve readability)
 > 
 > ?xml version="1.0"?>
 > <Catalog id="C31">
 > <object uri="http://developler.com/classdef;132">
 > 	<property uri="http://developer.com/propertyType;193">
 > 		1698.0||
 > 	</property
 > </object>
 > </Catalog>
 > 
 > I want to parse it using the following XSL
 > 
 > <?xml version="1.0" ?>
 > <!-- Passes a node set from one template to another -->
 > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 >     version="1.0">
 >     <xsl:strip-space elements="*" />
 >     <xsl:output method="xml" indent="yes" />
 > 	<xsl:template match="object" >
 > 	        <PRODUCT_ITEM >
 >             	<PRICE>
 > 	                <xsl:value-of select="property/@uri"/>
 >             	</PRICE>
 > 	</xsl:template>
 > </xsl:stylesheet>
 > 
 > The out put looks like this
 > 
 > <PRODUCT_ITEM>
 > <PRICE>
 > 		1698.0||
 > 	</PRICE>
 > </PRODUCT_ITEM>
 > 
 > I don't know why xsl:strip does not strip out the whitespaces around PRICE
 > tag.  I can use normalize-space() to make it work but that would be a hack.
 > I guess, xsl:strip=space should work, or am I using it incorrectly?

>From what I read in "XSLT Programmer's Reference" strip-space only
eliminates text nodes that consist entirely of whitespace, so it won't
have any affect on your "property" node which also has some digits, a
period ans two vertical bars in it as well as the whitespace.

I think you want to change your template to 

 	<xsl:template match="object" >
 	        <PRODUCT_ITEM >
             	<PRICE>
 	                <xsl:value-of select="normalize-space(property/@uri)"/>
             	</PRICE>
 	</xsl:template>

which uses the normalize-space function to remove leading and trailing
whitespace from the attribute value.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.