[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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

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
Keywords
xsl