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

Re: XPath help

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

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

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

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

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

Francis.
-- 
Francis Norton.

why not?


 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.