Re: XPath help

Subject: Re: XPath help
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Sun, 12 Nov 2000 12:56:34 +0000

Mathias Bonnard wrote:
> There might be a simpler version (especially avoiding the double test on
> preceding and following)...
for a sample file:
	<x name="a">x:a</x>
	<x name="b">x:b1</x>
	<x name="b">x:b2</x>
	<x name="c">x:c</x>

you can use test="count(//*[@name = ./@name]) = 1" :

<xsl:stylesheet xmlns:xsl="";
version="1.0" >
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="/">
			<xsl:apply-templates select="root"/>
	<xsl:template match="x">
		<xsl:if test="count(//*[@name = ./@name]) = 1">
			<xsl:copy-of select="."/>

It's probably not very efficient - you'd need a Muenchian solution (I
suspect) for large documents.

Francis Norton.

why not?

 XSL-List info and archive:

Current Thread