Solved

Eliminating duplicates in XML using XSlT..

Posted on 2009-05-15
17
403 Views
Last Modified: 2013-11-18
Hi Guys

I was hoping you could help me how to eliminate duplicates in XML using XSLT1.0
Below is my XML file
<softwareOffering>
<licensedFunction>
<licenseID>S0111R1</licenseID>
<description>Directory MaintenanceFac</description> <licenseOption>
<valueMetric>77D000</valueMetric>
<valueMetricDescription>Per Engine Registration</valueMetricDescription>
<chargeOption>NOCHARGE </chargeOption>
<chargeOptionDescription>No Charge</chargeOptionDescription>Charge</chargeOptionDescription>
<licenseType>SWSUBSUPRGST</licenseType>
<licenseTypeDescription>SW Subs and Sup t</licenseTypeDescription>
</licenseOption>
<licenseOption>
<valueMetric>4D9000</valueMetric>
<valueMetricDescription>Value Units</valueMetricDescription>
<chargeOption>CHINA4YEAR  </chargeOption>
<chargeOptionDescription>4 Year Support, China only</chargeOptionDescription>
<licenseType>SWSUBSCSUPPO</licenseType>
<licenseTypeDescription>SW Subscription and Support</licenseTypeDescription>
</licenseOption>
<licenseOption>
<valueMetric>4D9000</valueMetric>
<valueMetricDescription>Value Units</valueMetricDescription>
<chargeOption>ASC         </chargeOption>
<chargeOptionDescription>Annual Support Charge</chargeOptionDescription>
<licenseType>SWSUBSCSUPPO</licenseType>
<licenseTypeDescription>SW Subscription and Support</licenseTypeDescription>
</licenseOption>
<licenseOption>
<valueMetric>4D9000</valueMetric>
<valueMetricDescription>Value Units</valueMetricDescription>
<chargeOption>MSC         </chargeOption>
<chargeOptionDescription>Monthly Support Charge</chargeOptionDescription>
<licenseType>SWSUBSCSUPPO</licenseType>
<licenseTypeDescription>SW Subscription and Support</licenseTypeDescription>
</licenseOption>
</licensedFunction>
<licensedFunction>
<licenseID>S0111PZ</licenseID>
<description>Performance Toolkit for VM</description>
<licenseOption>
<valueMetric>77D000</valueMetric>
<valueMetricDescription>Per Engine Registration</valueMetricDescription>
<chargeOption>NOCHARGE    </chargeOption>
<chargeOptionDescription>No Charge</chargeOptionDescription>
<licenseType>SWSUBSUPRGST</licenseType>
<licenseTypeDescription>SW Subs and Sup Rgst</licenseTypeDescription>
</licenseOption>
<licenseOption>
<valueMetric>4D9000</valueMetric>
<valueMetricDescription>Value Units</valueMetricDescription>
<chargeOption>CHINA4YEAR  </chargeOption>
<chargeOptionDescription>4 Year Support, China only</chargeOptionDescription>
<licenseType>SWSUBSCSUPPO</licenseType>
<licenseTypeDescription>SW Subscription and Support</licenseTypeDescription>
</licenseOption>
<licenseOption>
<valueMetric>4D9000</valueMetric>
<valueMetricDescription>Value Units</valueMetricDescription>
<chargeOption>ASC     </chargeOption>
<chargeOptionDescription>Annual Support Charge</chargeOptionDescription>
<licenseType>SWSUBSCSUPPO</licenseType>
<licenseTypeDescription>SW Subscription and Support</licenseTypeDescription>
</licenseOption>
</licensefunction>


Here i want to print LIcenseID,ValueMetric,ValueMetric Description..
ease consider as high priorty

Here is my xsl which is not eliminating duplicates in xslt
<xsl:key name="valueMetric" match="..//licenseOption" use="valueMetric" />
  <!--  Output method  -->
  <xsl:output method="html" omit-xml-declaration="yes" indent="yes" />
<xsl:for-each select="../licensedFunction/licenseID>
  <xsl:for-each select="licenseOption[count(. | key('valueMetric', valueMetric)[1]) = 1]">
    <tr>
  <xsl:if test="(position() mod 2 = 0)">
  <xsl:attribute name="class">gray</xsl:attribute>
  </xsl:if>
  <td>
  <xsl:variable name="valuemetricid" select="valueMetric" />
  <xsl:variable name="licenceid" select="../licenseID" />
  <small>
  <a href="{contextRoot}{servletPath}iSoftwareorderinfoseb2_result.jsp?type=Licence&licenceid={$licenceid}&valuemetricid={$valuemetricid}">
  <xsl:value-of select="../../productId/typeCode" />
  <xsl:value-of select="../../productId/modelCode" />
  </a>
  </small>
  </td>
 <td nowrap="1">
 <small>
  <xsl:value-of select="../licenseID" />
   <xsl:value-of select="valueMetric" />
  </small>
  </td>
   <td nowrap="1">
  <small>
  <xsl:value-of select="valueMetricDescription" />
  </small>
  </td>
  <td nowrap="1">
  <small>CHARGE</small>
  <script type="text/javascript">v++;</script>
  </td>
  </tr>
  </xsl:for-each>
</xsl:stylesheet>
Thanks

0
Comment
Question by:kommichowdary
  • 10
  • 7
17 Comments
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 500 total points
ID: 24393890
I think this is what you need
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output indent="yes"/>

    <xsl:key name="uniq" match="licenseOption" use="concat(../licenseID, valueMetric, valueMetricDescription)"/>

    <xsl:template match="softwareOffering">

    <table border="1">

        <tr>

            <th>LicenseID</th>

            <th>ValueMetric</th>

            <th>ValueMetric Description</th>

        </tr>

        <xsl:apply-templates select="licensedFunction/licenseOption[generate-id() = generate-id(key('uniq', concat(../licenseID, valueMetric, valueMetricDescription))[1])]">
 

        </xsl:apply-templates>

    </table>

</xsl:template>

    <xsl:template match="licenseOption">

        <tr>

            <td><xsl:value-of select="../licenseID"/></td>

            <td><xsl:value-of select="valueMetric"/></td>

            <td><xsl:value-of select="valueMetricDescription"/></td>

        </tr>

    </xsl:template>

</xsl:stylesheet>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24393893
The technique I use for unique fields is known as muenchian grouping
http://www.jenitennison.com/xslt/grouping/muenchian.html
0
 

Author Comment

by:kommichowdary
ID: 24395179
Can u make it elaborate ...
<softwareOffering><licensedFunction><licenseID>S0111R1</licenseID><description>Directory Maintenance Fac</description><licenseOption><valueMetric>77D000</valueMetric><valueMetricDescription>Per Engine Registration</valueMetricDescription><chargeOption>NOCHARGE    </chargeOption><chargeOptionDescription>No Charge</chargeOptionDescription><licenseType>SWSUBSUPRGST</licenseType><licenseTypeDescription>SW Subs and Sup Rgst</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>CHINA4YEAR  </chargeOption><chargeOptionDescription>4 Year Support, China only</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>ASC         </chargeOption><chargeOptionDescription>Annual Support Charge</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>MSC         </chargeOption><chargeOptionDescription>Monthly Support Charge</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>NOCHARGE    </chargeOption><chargeOptionDescription>No Charge</chargeOptionDescription><licenseType>DECLINESANDS</licenseType><licenseTypeDescription>Decline Subscribe and Suppt.</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>ONEYRRESEL  </chargeOption><chargeOptionDescription>Reseller One Year</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption></licensedFunction><licensedFunction><licenseID>S0111PZ</licenseID><description>Performance Toolkit for VM</description><licenseOption><valueMetric>77D000</valueMetric><valueMetricDescription>Per Engine Registration</valueMetricDescription><chargeOption>NOCHARGE    </chargeOption><chargeOptionDescription>No Charge</chargeOptionDescription><licenseType>SWSUBSUPRGST</licenseType><licenseTypeDescription>SW Subs and Sup Rgst</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>CHINA4YEAR  </chargeOption><chargeOptionDescription>4 Year Support, China only</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>ASC         </chargeOption><chargeOptionDescription>Annual Support Charge</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>MSC         </chargeOption><chargeOptionDescription>Monthly Support Charge</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>NOCHARGE    </chargeOption><chargeOptionDescription>No Charge</chargeOptionDescription><licenseType>DECLINESANDS</licenseType><licenseTypeDescription>Decline Subscribe and Suppt.</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>ONEYRRESEL  </chargeOption><chargeOptionDescription>Reseller One Year</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption></licensedFunction><licensedFunction><licenseID>S0111R0</licenseID><description>Resource Access Control Fac</description><licenseOption><valueMetric>77D000</valueMetric><valueMetricDescription>Per Engine Registration</valueMetricDescription><chargeOption>NOCHARGE    </chargeOption><chargeOptionDescription>No Charge</chargeOptionDescription><licenseType>SWSUBSUPRGST</licenseType><licenseTypeDescription>SW Subs and Sup Rgst</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>CHINA4YEAR  </chargeOption><chargeOptionDescription>4 Year Support, China only</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>ASC         </chargeOption><chargeOptionDescription>Annual Support Charge</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>MSC         </chargeOption><chargeOptionDescription>Monthly Support Charge</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>NOCHARGE    </chargeOption><chargeOptionDescription>No Charge</chargeOptionDescription><licenseType>DECLINESANDS</licenseType><licenseTypeDescription>Decline Subscribe and Suppt.</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>ONEYRRESEL  </chargeOption><chargeOptionDescription>Reseller One Year</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption></licensedFunction><licensedFunction><licenseID>S013T6B</licenseID><description>RSCS Feature S&amp;S</description><licenseOption><valueMetric>77D000</valueMetric><valueMetricDescription>Per Engine Registration</valueMetricDescription><chargeOption>NOCHARGE    </chargeOption><chargeOptionDescription>No Charge</chargeOptionDescription><licenseType>SWSUBSUPRGST</licenseType><licenseTypeDescription>SW Subs and Sup Rgst</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>ASC         </chargeOption><chargeOptionDescription>Annual Support Charge</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>MSC         </chargeOption><chargeOptionDescription>Monthly Support Charge</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>NOCHARGE    </chargeOption><chargeOptionDescription>No Charge</chargeOptionDescription><licenseType>DECLINESANDS</licenseType><licenseTypeDescription>Decline Subscribe and Suppt.</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>ONEYRRESEL  </chargeOption><chargeOptionDescription>Reseller One Year</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption></licensedFunction><licensedFunction><licenseID>S0111PX</licenseID><description>z/VM Version 5</description><licenseOption><valueMetric>77D000</valueMetric><valueMetricDescription>Per Engine Registration</valueMetricDescription><chargeOption>NOCHARGE    </chargeOption><chargeOptionDescription>No Charge</chargeOptionDescription><licenseType>SWSUBSUPRGST</licenseType><licenseTypeDescription>SW Subs and Sup Rgst</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>CHINA4YEAR  </chargeOption><chargeOptionDescription>4 Year Support, China only</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>ASC         </chargeOption><chargeOptionDescription>Annual Support Charge</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>MSC         </chargeOption><chargeOptionDescription>Monthly Support Charge</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>NOCHARGE    </chargeOption><chargeOptionDescription>No Charge</chargeOptionDescription><licenseType>DECLINESANDS</licenseType><licenseTypeDescription>Decline Subscribe and Suppt.</licenseTypeDescription></licenseOption><licenseOption><valueMetric>4D9000</valueMetric><valueMetricDescription>Value Units</valueMetricDescription><chargeOption>ONEYRRESEL  </chargeOption><chargeOptionDescription>Reseller One Year</chargeOptionDescription><licenseType>SWSUBSCSUPPO</licenseType><licenseTypeDescription>SW Subscription and Support</licenseTypeDescription></licenseOption></licensedFunction></softwareoffering>

This is the output i am getting ....
 
The SAP ESW based Search results are displayed below  
Program  DescriptionCode  Description  Additional information Doc.  Type

Program DescriptionCode Description Additional information Doc. Type
5741SNS S0111R1 / 77D000 Directory Maintenance Fac Per Engine Registration CHARGE
5741SNS S0111R1 / 4D9000 Directory Maintenance Fac Value Units CHARGE
5741SNS S0111R1 / 4D9000 Directory Maintenance Fac Value Units CHARGE
5741SNS S0111R1 / 4D9000 Directory Maintenance Fac Value Units CHARGE
5741SNS S0111R1 / 4D9000 Directory Maintenance Fac Value Units CHARGE
5741SNS S0111R1 / 4D9000 Directory Maintenance Fac Value Units CHARGE
5741SNS S0111PZ / 77D000 Performance Toolkit for VM Per Engine Registration CHARGE
5741SNS S0111PZ / 4D9000 Performance Toolkit for VM Value Units CHARGE
5741SNS S0111PZ / 4D9000 Performance Toolkit for VM Value Units CHARGE
5741SNS S0111PZ / 4D9000 Performance Toolkit for VM Value Units CHARGE
5741SNS S0111PZ / 4D9000 Performance Toolkit for VM Value Units CHARGE
5741SNS S0111PZ / 4D9000 Performance Toolkit for VM Value Units CHARGE
5741SNS S0111R0 / 77D000 Resource Access Control Fac Per Engine Registration CHARGE
5741SNS S0111R0 / 4D9000 Resource Access Control Fac Value Units CHARGE
5741SNS S0111R0 / 4D9000 Resource Access Control Fac Value Units CHARGE
5741SNS S0111R0 / 4D9000 Resource Access Control Fac Value Units CHARGE
5741SNS S0111R0 / 4D9000 Resource Access Control Fac Value Units CHARGE
5741SNS S0111R0 / 4D9000 Resource Access Control Fac Value Units CHARGE
5741SNS S013T6B / 77D000 RSCS Feature S&S Per Engine Registration CHARGE
5741SNS S013T6B / 4D9000 RSCS Feature S&S Value Units CHARGE
5741SNS S013T6B / 4D9000 RSCS Feature S&S Value Units CHARGE
5741SNS S013T6B / 4D9000 RSCS Feature S&S Value Units CHARGE
5741SNS S013T6B / 4D9000 RSCS Feature S&S Value Units CHARGE
5741SNS S0111PX / 77D000 z/VM Version 5 Per Engine Registration CHARGE
5741SNS S0111PX / 4D9000 z/VM Version 5 Value Units CHARGE
5741SNS S0111PX / 4D9000 z/VM Version 5 Value Units CHARGE
5741SNS S0111PX / 4D9000 z/VM Version 5 Value Units CHARGE
5741SNS S0111PX / 4D9000 z/VM Version 5 Value Units CHARGE
5741SNS S0111PX / 4D9000 z/VM Version 5 Value Units CHARGE

OUTPUT I AM EXPECTING:::
Program Description Code Description Additional Information Doc. Type
5741SNS  S0111R1 / 77D000 Directory Maintenance Fac Per Engine Registration CHARGE
5741SNS  S0111R1 / 4D9000 Directory Maintenance Fac Value Units CHARGE
5741SNS  S0111PZ / 77D000 Performance Toolkit for VM Per Engine Registration CHARGE
5741SNS  S0111PZ / 4D9000 Performance Toolkit for VM Value Units CHARGE
5741SNS  S0111R0 / 77D000 Resource Access Control Fac Per Engine Registration CHARGE
5741SNS  S0111R0 / 4D9000 Resource Access Control Fac Value Units CHARGE
5741SNS  S013T6B / 77D000 RSCS Feature S&S Per Engine Registration CHARGE
5741SNS  S013T6B / 4D9000 RSCS Feature S&S Value Units CHARGE
5741SNS  S0111PX / 77D000 z/VM Version 5 Per Engine Registration CHARGE
5741SNS  S0111PX / 4D9000 z/VM Version 5 Value Units CHARGE


0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24395279
Can you please post the file in the code snippet field, it looses some entities this way
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24395330
Output I am getting is this

It is exactly what you want.

I seem to notice that you have changed the XSLT.
I think you introduced a bug, it would be nice if you posted the new XSLT... evidently
<?xml version="1.0" encoding="utf-8"?>

<table border="1">

   <tr>

      <th>LicenseID</th>

      <th>ValueMetric</th>

      <th>ValueMetric Description</th>

   </tr>

   <tr>

      <td>S0111R1</td>

      <td>77D000</td>

      <td>Per Engine Registration</td>

   </tr>

   <tr>

      <td>S0111R1</td>

      <td>4D9000</td>

      <td>Value Units</td>

   </tr>

   <tr>

      <td>S0111PZ</td>

      <td>77D000</td>

      <td>Per Engine Registration</td>

   </tr>

   <tr>

      <td>S0111PZ</td>

      <td>4D9000</td>

      <td>Value Units</td>

   </tr>

   <tr>

      <td>S0111R0</td>

      <td>77D000</td>

      <td>Per Engine Registration</td>

   </tr>

   <tr>

      <td>S0111R0</td>

      <td>4D9000</td>

      <td>Value Units</td>

   </tr>

   <tr>

      <td>S013T6B</td>

      <td>77D000</td>

      <td>Per Engine Registration</td>

   </tr>

   <tr>

      <td>S013T6B</td>

      <td>4D9000</td>

      <td>Value Units</td>

   </tr>

   <tr>

      <td>S0111PX</td>

      <td>77D000</td>

      <td>Per Engine Registration</td>

   </tr>

   <tr>

      <td>S0111PX</td>

      <td>4D9000</td>

      <td>Value Units</td>

   </tr>

</table>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24395354
No need to post the XML again, I fixed it manually
Now I need the XSL, in order to continue
0
 

Author Comment

by:kommichowdary
ID: 24396426
Here is the XSL code...<!-- Output method -->
<xsl:key name="uniq" match="offeringInformation/softwareOffering/licensedFunction/" use="concat(../licenseID, valueMetric)"/>
      <xsl:output method="html" omit-xml-declaration="yes" indent="yes"
      <xsl:call-template name="starting">
                  <xsl:with-param name="s1" select="0" />
            </xsl:call-template>
      </xsl:template>


      <xsl:template match="offeringInformation" name="starting">
                        <head>
                  <script type="text/javascript">var v = 0;</script>

            </head>

            <table class="basic-table" cellspacing="1" cellpadding="0" width="80%" style="margin-top:2em;">
    <tr>
        <td colspan="7"></td>
    </tr>
    <tr>
   


                  <xsl:for-each
                        select="offeringInformation/softwareOffering/licensedFunction/licenseOption">                        

                        <tr>
                              <xsl:if test="(position() mod 2 = 0)">

                                    <xsl:attribute name="class">gray</xsl:attribute>
                              </xsl:if>
                              <td>
                                    <xsl:variable name="valuemetricid"

select="valueMetric">
                                    </xsl:variable>
                              
      <xsl:variable name="licenceid" select="../licenseID">
                                    </xsl:variable>
                                    
                                    <small>
                                          <a
                                                href="Softwareor.jsp?type=Licence&amp;licenceid={$licenceid}&amp;valuemetricid={$valuemetricid}">

                                                <xsl:value-of
                                                      select="../../productId/typeCode" />
                                                <xsl:value-of
                                                      select="../../productId/modelCode" />
                                          </a>
                                    </small>
                              </td>
                              <td nowrap="1">
                                    <small>
                                          <xsl:value-of select="../licenseID" />
                                          /
                                          <xsl:value-of select="valueMetric" />
                                    </small>
                              </td>
                              <td nowrap="1">
                                    <small>
                                          <xsl:value-of select="../description" />
                                    </small>
                              </td>
                              <td nowrap="1">
                                    <small>
                                          <xsl:value-of
                                                select="valueMetricDescription" />
                                    </small>
                              </td>
                              <td nowrap="1">
                                    <small>CHARGE</small>
                                    <script type="text/javascript">v++;</script>

                              </td>
                        </tr>
                        
                   </xsl:if>            
                  </xsl:for-each>
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24396527
Some comments
- if you post XML or XSL, use the code snippet pane, then the code comes out with a lot better quality
- if you post an XSLT, make sure what you post is complete
I spend too much time fixing this rubbish before I can start working on it, whilst it is only a small effort for you to copy correctly
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24396543
Too much was lost in your copying, I can't fix it in a way I can see what was wrong, please post again
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24396611
also you XML is in complete
I see this XPath
<xsl:for-each  select="offeringInformation/softwareOffering...
implying there is an offeringInformation element around what you posted
If an offeringInformation can contain multiple softwareOfferings, that could allready be the cause for duplication

How can you expect us to answer your question and help you debugging,
if you poste uncomplete data and uncomplete requirements.
This way you are wasting a lot of time from experts that could use that time to help others,
0
 

Accepted Solution

by:
kommichowdary earned 0 total points
ID: 24405856
Hello,
         In my last code snippet there were unnecessary tags  which caused the confusion ...Sorry...I have attached the correct code snippet.
Thanks
<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output indent="yes"/>

<xsl:key name="licenseID" match="softwareOffering/licensedFunction" use="licenseID" />

<xsl:key name="valueMetric" match="softwareOffering/licensedFunction" use="valueMetric" />

<xsl:template match="softwareOffering">

<xsl:for-each select="softwareOffering/licensedFunction[count(. | key('licenseID', licenseID)[1]) = 1]">

<xsl:for-each select="licenseOption[count(. | key('valueMetric', valueMetric)[1]) = 1]">

<xsl:variable name="valuemetricid"  select="../valueMetric"> 

</xsl:variable>

<xsl:variable name="licenceid" select="../licenseID">

</xsl:variable>

<xsl:variable name="valueMetricDescription"  select="../valueMetricDescription">

</xsl:variable>

<small>

<xsl:value-of select="../licenseID" />

<xsl:value-of select="../valueMetric" />

<xsl:value-of select="../ValueMetricDescription" />

</small>

</xsl:for-each>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24407603
Well my friend,
what was wrong with my code?
You completely changed it, in order to have the same effect as my first example, except that it worked, and now it does not.
I started changing your example, put some effort in it and will likely end up with the same code as before.
So, can you tell me what was wrong with my example, and why you changed it, because you definitely did not improve it.
So simply tell me what functionality needs to be changed from my example, and I will help you with that, but I will not work on the code you just dumped here
0
 

Author Comment

by:kommichowdary
ID: 24409684
Sorry Buddy ..I accept your first Solution..Thanks a lot for your solution...It really helped me a lot...

Thanks...
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24409841
No problem,
please note that I am willing to help to change it to your needs if needed,
0
 

Author Comment

by:kommichowdary
ID: 24410289
Thankyou much..but i changed according to my need....

Thanks
0
 

Author Comment

by:kommichowdary
ID: 24410297
With which you gave piece of code in XML...that is really really nice...
0
 

Author Comment

by:kommichowdary
ID: 24451443
I got exact solution...what i needed ..so thanks to the expertee who provided solution..Thanks alot  Buddy :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now