[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: joining nodes
should be transformed to the (text) output: >v21n1 v11 n2 > v21 >v22 because n1 is associated to v11 and v21 and n2 is associated to v21 and v22 in <aaa/> and <bbb/> respectively. Did you mean n1 v11 v21 n2 v12 ** v22 because n1 is associated to v11 and v21 and n2 is associated to v12 and v22 in <aaa/> and <bbb/> respectively. See if there was a typo in your n2 values. Any way.. David Suggested... <xsl:for-each select="aaa/name"> <xsl:value-of select="."/> <xsl:value-of select="../value1"/> <xsl:value-of select="/join1/bbb/a[name=current()]/value2 </xsl:for-each> Will this work if he had <ccc> <a> <name>n1</name> <value2>v31</value2> </a> <a> <name>n2</name> <value2>v32</value2> </a> </ccc> and <ddd> and .... <nnn>?? I think it is better to group them by Name and then Print their values. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key match="//a" name="names" use="name/text()"/> <xsl:template match="join1"> <xsl:for-each select="//a[generate-id(.) = generate-id(key('names',name/text())[1])]"> <xsl:variable name="name" select="name/text()"/> <xsl:value-of select = "$name"/> <br/> <xsl:for-each select="key('names',$name)"> <xsl:value-of select = "*[contains(name(),'value')]/text()"/> <br/> </xsl:for-each> <hr/> </xsl:for-each> </xsl:template> </xsl:stylesheet> The above is in XSLT1 you could use more advanced grouping techniques of XSLT2 to do the same. Try if this works. Vasu From: David Carlisle <davidc@xxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: joining nodes Date: Thu, 16 Feb 2006 15:27:04 GMT _________________________________________________________________ The new MSN Search Toolbar now includes Desktop search! http://toolbar.msn.co.uk/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|