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

RE: merging unknown nodes

Subject: RE: merging unknown nodes
From: "Kevin Jones" <kjouk@xxxxxxxxxxx>
Date: Wed, 1 Nov 2000 18:22:02 -0400 (EST)
javascript merge nodes
Jon,

This should do the trick,

<xsl:for-each select="/PRODUCTS/PRODUCT/OPTIONLIST">
	<xsl:if test="not (@name = preceding::OPTIONLIST/@name)">
		<xsl:variable name="name" select="@name"/>
		<OPTIONLIST name="{$name}">
			<xsl:copy-of select="/PRODUCTS/PRODUCT/OPTIONLIST/*[../@name=$name]"/>
		</OPTIONLIST>
	</xsl:if>
</xsl:for-each>

Kev.

>
>
> I'm new to XSL(T) and so far I have not been able to think of a way of
> achieving the required transform using XSLT and I think I'm going
> to have to
> result to using some JavaScript or may be some plain old C code :-(
>
> What I want to be able to do is transform this:
>
> <PRODUCTS>
>     <PRODUCT name="bill_product">
>         <OPTIONLIST name="fred"> <!-- The first 'fred' option list -->
>             <OPTION>fred1</OPTION>
>             <OPTION>fred2</OPTION>
>         </OPTIONLIST>
>         <OPTIONLIST name="george">
>             <OPTION>george1</OPTION>
>         </OPTIONLIST>
>     </PRODUCT>
>
>     <PRODUCT name="bob_product">
>         <OPTIONLIST name="fred">   <!-- The second 'fred' optionlist -->
>             <OPTION>fred3</OPTION>
>             <OPTION>fred4</OPTION>
>         </OPTIONLIST>
>         <OPTIONLIST name="george">
>             <OPTION>george2</OPTION>
>         </OPTIONLIST>
>     </PRODUCT>
> <PRODUCTS>
>
> Into this:
>
> <OPTIONLIST name="fred">	<!-- All the 'fred' optionlist's merged into
> one -->
>     <OPTION>fred1</OPTION>
>     <OPTION>fred2</OPTION>
>     <OPTION>fred3</OPTION>
>     <OPTION>fred4</OPTION>
> </OPTIONLIST>
> <OPTIONLIST name="george">	<!-- All the 'george' optionlist's
> merged into
> one -->
>     <OPTION>george1</OPTION>
>     <OPTION>george2</OPTION>
> </OPTIONLIST>
>
> If the transform was literally just this one case then it wouldn't be a
> problem however I want to be able to merge all OPTIONLIST's with the same
> name into one OPTIONLIST with that name i.e. I don't want to be limited to
> just 'fred' and 'george' option lists but I want to have any number of
> different named OPTIONLIST's and have them merged.
>
> Is this possible using just XSLT (in which case I guess I just
> don't have a
> good enough understanding yet) or am I going to have to use a procedural
> langauge to solve this part?
>
> TIA,
>
> Jon Payne
>
>
> TTPCom Ltd				Tel: +44 1483 565050
> 20 Nugent Road
> Surrey Research Park
> Guildford
> Surrey GU2 7DF  UK            http://www.ttpcom.com
>
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




 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.