Re: [xep-support] set theory in XSLT

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Mon Jun 29 2009 - 04:58:21 PDT

It is unclear to me why you would be so impatient for free advice to
send your message three times without an immediate reply. This is a
volunteer list.

At 2009-06-29 16:24 +0530, Somanna Ramaiah wrote:
>I have a xml
>
>it has set of nodes, say group_1 and group_2
>
>i need to get the temporarytree groups ,
>
>1) common in both 1 and 2
>2) only in WSU group1 - group2
>3) only in HWMA group2 - group1

You've described the inputs and the outputs, but you haven't
described what problem with XSLT you are having. How much of the
solution have you tried yourself? What intermediate answers did you
get? What issues with XSLT are causing you to give up on your solution?

Or are you just asking volunteers to do your work for you?

>Please help me to resolve this problem

This is quite straightforward in XSLT by using the "=" operator which
acts on sets in a predictable fashion. Perhaps this is where your
problem was in your own code. The test returns false when all
members of both operands have been tested and all tests return
false. The test returns true when any pair of operands tests true.

I hope the example below helps. But please do not demand volunteer
support to be done so quickly as we are all on the list to help each
other, not to do each other's work on short demand.

. . . . . . . . . . . Ken

t:\ftemp>type som.xml
<componentTempTree>
         <components NAME="group_1">
                 <group num="8000" >
                         <row>
                                 <component no="2"
id="67869568611601">row</component>
                         </row>
                 </group>
                 <group num="8000" >
                         <row>
                                 <component no="3"
id="34118726711601">row</component>
                         </row>
                 </group>
                 <group num="8000" >
                         <row>
                                 <component no="1"
id="53663065341601">row</component>
                         </row>
                         <row>
                                 <component no="5"
id="53663065341601">row</component>
                         </row>
                 </group>
         </components>
         <components NAME="group_2">
                         <group num="1" >
                                 <row>
                                         <component no="1"
id="53663065341601">row</component>
                                 </row>
                                 <row>
                                         <component no="5"
id="53663065341601">row</component>
                                 </row>
                         </group>
                         <group num="1" >
                                 <row>
                                         <component no="4"
id="49230855341601">row</component>
                                 </row>
                         </group>
                 </components>

</componentTempTree>

t:\ftemp>call xslt som.xml som.xsl
<?xml version="1.0" encoding="utf-8"?>
<componentTempTree>
    <components NAME="group_1">
       <group num="8000">

          <row>

             <component no="2" id="67869568611601">row</component>

          </row>

       </group>
       <group num="8000">

          <row>

             <component no="3" id="34118726711601">row</component>

          </row>

       </group>
    </components>
    <components NAME="group_2">
       <group num="1">

          <row>

             <component no="4" id="49230855341601">row</component>

          </row>

       </group>
    </components>
    <components NAME="group_1_group2">
       <group num="8000">

          <row>

             <component no="1" id="53663065341601">row</component>

          </row>

          <row>

             <component no="5" id="53663065341601">row</component>

          </row>

       </group>
    </components>
</componentTempTree>
t:\ftemp>type som.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 version="1.0">

<xsl:output indent="yes"/>

<xsl:template match="componentTempTree">
   <xsl:copy>
     <xsl:variable name="group_1"
                   select="components[@NAME='group_1']/group"/>
     <xsl:variable name="group_2"
                   select="components[@NAME='group_2']/group"/>
     <components NAME="group_1">
       <xsl:copy-of select="$group_1[not(row/component/@no =
                                         $group_2/row/component/@no)]"/>
     </components>
     <components NAME="group_2">
       <xsl:copy-of select="$group_2[not(row/component/@no =
                                         $group_1/row/component/@no)]"/>
     </components>
     <components NAME="group_1_group2">
       <xsl:copy-of select="$group_1[row/component/@no =
                                     $group_2/row/component/@no]"/>
     </components>
   </xsl:copy>
</xsl:template>

</xsl:stylesheet>

t:\ftemp>rem Done!

--
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/f/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/f/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/terms-of-service.html
Received on Mon Jun 29 05:55:31 2009

This archive was generated by hypermail 2.1.8 : Mon Jun 29 2009 - 05:55:33 PDT