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

RE: only display if subnodes occur more than once

Subject: RE: only display if subnodes occur more than once
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Thu, 23 Jun 2005 13:14:47 +0100
RE:  only display if subnodes occur more than once
> I'm stuck again with my XSL. My XML Structure looks like:
>
> <root>
> 	<sub_a>
> 		<elem_1/>
> 		<elem_2/>
> 		<elem_3/>
> 	</sub_a>
> 	<sub_b>
> 		<elem_1/>
> 		<elem_2/>
> 		<elem_2/>
> 		<elem_2/>
> 		<elem_3/>
> 	</sub_b>
> 	<sub_c>
> 		<elem_1/>
> 		<elem_2/>
> 		<elem_3/>
> 	</sub_c>
> </root>
>
> The thing I want to do is display the element sub_b, because
> it has subnodes which occur more than once (elem_2). I really
> have no idea how to test for this - playing around for nearly
> two hours now. Im using a loop like <xsl:for-each
> select="/root/*"> and the output should look like
>
> sub_b (this is the header)
> elem_2
> elem_2 (these are the 3 values of elem_2)
> elem_2

How about:

<xsl:template match="sub_a|sub_b|sub_c">
  <xsl:variable name="copy"
select="boolean(*/following-sibling::*[local-name() =
preceding-sibling::*/local-name()])"/>

  <xsl:if test="$copy">
    <xsl:copy-of select="."/>
  </xsl:if>
</xsl:template>

cheers
andrew

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.