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

how to use normalize-space

Subject: how to use normalize-space
From: Linda van den Brink <lvdbrink@xxxxxxx>
Date: Thu, 9 Dec 1999 14:29:41 +0100
how to use normalize
Hi all, 

I have a case where I want to process an element based on its content. The
problem is that the element in my source often has whitespace so that it
doesn't match the text I want to find. I guess I have to use normalize-space
but I don't know the exact syntax. When I remove the extra space from my
source manually the XSL fragment below works. 

Here's a fragment of my source: 
	<p>
	<list>
		<listitem>
		Related topics</listitem>
		<listitem>
			<link type="manual" ref="whOM000021">lot
control</link>
		</listitem>
		<listitem>
			<link type="manual" ref="whOM000022">variable lot
features</link>
		</listitem>
		<listitem>
			<link type="manual" ref="whOM000023">lot
tracking</link>
		</listitem>
		<listitem>
			<link type="manual" ref="whOM000024">Lots</link>
		</listitem>
	</list>
	</p>

Here's the applicable fragment of my XSL. It should select a listitem if
it's value is 'Related topics' (or a variation of that with extra
whitespace) and create a ListTitle for that, and create ListItem tags for
all listitems with another value. 

<xsl:template match="p[list]">
	<List>
		<xsl:if test="normalize-space(list[listitem='Related
topics'])">
			<ListTitle><xsl:value-of
select="list/listitem"/></ListTitle>
		</xsl:if>	
		<xsl:for-each select="list/listitem"><!-- if it's value is
not 'Related topics' -->
			<ListItem><xsl:apply-templates/></ListItem>
		</xsl:for-each>
	</List>
</xsl:template>

The output I want would be 
<List>
	<ListTitle>Related topics</ListTitle>
	<ListItem><Link role="manual" href="whOM000021">lot
control</Link></ListItem>
	<ListItem><Link role="manual" href="whOM000022">variable lot
features</Link></ListItem>
	<ListItem><Link role="manual" href="whOM000023">lot
tracking</Link></ListItem>
	<ListItem><Link role="manual"
href="whOM000024">Lots</Link></ListItem>
</List>

Thanks for any help!


 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.