xsl-list
[Top] [All Lists]

Re: [xsl] Conditional Merging of the node based child value match

2006-09-16 00:55:28
Senthilkumaravelan Krishnanatham wrote:

Hi All,
I have following xml as my input and I need to group the item number with the corresponding line item number and form the out as mentioned below. I would like to how to group the nodes based the condition and form the output.
Hi Senthil,

I don't see such a thing as a line item number in your code, but it appears to me you are actually talking about ITEM_NUMBER that must equal, and you want to group the CTO_INFO elements inside the CTOS section, when these ITEM_NUMBER match. Something like that. If that's so, here's a stylesheet that (almost) produces that output you have. You probably want to tweak it a bit. For instance, it currently outputs an empty CTOS element when there are no matchin ITEM_NUMBER nodes.

Have fun with it,

Cheers,
Abel Braaksma
http://abelleba.metacarpus.com

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
   <xsl:output indent="yes" />
<xsl:template match="/">
       <ORDER>
           <xsl:apply-templates select="ORDER/TAB_ITEM" />
       </ORDER>
   </xsl:template>
   <xsl:template match="TAB_ITEM">
       <xsl:variable name="nr" select="ITEM_NUMBER" />
       <TAB_ITEM>
           <xsl:copy-of select="*" />
           <CTOS>
<xsl:apply-templates select="../TAB_CTO[ITEM_NUMBER = $nr]/CTO_INFO" />
           </CTOS>
       </TAB_ITEM>
   </xsl:template>
<xsl:template match="CTO_INFO">
       <xsl:copy-of select="." />
   </xsl:template>
</xsl:stylesheet>




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>