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

Re: joining nodes

Subject: Re: joining nodes
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Thu, 16 Feb 2006 15:56:59 +0000
xsl name
should be transformed to the (text) output:

n1
 v11
>v21
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

first one is just something like
<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>

second one is something like

<xsl:for-each select="aaa/ident">
: <xsl:value-of select="."/>
  <xsl:text> </xsl:text>
  <xsl:value-of select="/join2/bbb/a[ident=current()]/subject
</xsl:for-each>


David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


_________________________________________________________________
The new MSN Search Toolbar now includes Desktop search! http://toolbar.msn.co.uk/


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.