Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Multiple Groupings with Muenchian Method

From: Rohit <rosharma@-----.--->
To: NULL
Date: 9/3/2007 5:35:00 AM

A newbies question on multiple groupings:

Input XML:

<?xml version="1.0" encoding="utf-8"?>
<root>
  <a title="Heavy Vehicle Driver Fatigue Reform Information">
    <g compliance_issue_title="Transport of Materials and Goods">
      <j titlelong="Commonwealth of Australia" />
    </g>
    <g compliance_issue_title="Working Hours">
      <j titlelong="Commonwealth of Australia" />
    </g>
  </a>
  <a title="Marine and Safety Regulations - Collision">
    <g compliance_issue_title="Transport of Materials and Goods">
      <j titlelong="New South Wales" />
      <j titlelong="Tasmania" />
    </g>
    <g compliance_issue_title="Emergency Preparedness and Response">
      <j titlelong="New South Wales" />
      <j titlelong="Tasmania" />
    </g>
  </a>
  <a title="Road Transport (Mass, Loading and Access) Amendment
Regulation - Fees">
    <g compliance_issue_title="Transport of Materials and Goods">
      <j titlelong="New South Wales" />
    </g>
  </a>
</root>


Output :
<root>
  <g> "Transport of Materials and Goods"
    <j> "Commonwealth of Australia"
      <a title="Heavy Vehicle Driver Fatigue Reform Information"/>
    </j>
    <j> "New South Wales"
      <a title="Marine and Safety Regulations - Collision"/>
      <a title="Road Transport (Mass, Loading and Access) Amendment
Regulation - Fees"/>
    </j>
    <j>"Tasmania"
      <a title="Marine and Safety Regulations - Collision"/>
    </j>
  </g>
  <g> "Working Hours"
    <j>"Commonwealth of Australia"
      <a title="Heavy Vehicle Driver Fatigue Reform Information"/>
    </j>
  </g>
  <g"Emergency Preparedness and Response"
    <j>"New South Wales"
      <a title="Marine and Safety Regulations - Collision"/>
    </j>
    <j>"Tasmania"
      <a title="Marine and Safety Regulations - Collision"/>
    </j>
  </g>
</root>

The XSLT I got to :

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
  <xsl:key name="bpjur" match="//j" use="concat(../
@compliance_issue_title,'',@titlelong)" />
  <xsl:template match="/">
    <root>
    <xsl:for-each select="//j[generate-id() = generate-id(key('bpjur',
concat(../@compliance_issue_title,'',@titlelong))[1])]">
       <g>
         <xsl:value-of select ="../@compliance_issue_title"/>
         <j>
           <xsl:value-of select ="@titlelong"/>
         </j>
       </g>
    </xsl:for-each>
      </root>
  </xsl:template>

</xsl:stylesheet>

Which gives me the following output:

<?xml version="1.0" encoding="utf-8"?>
<root>
  <g>Transport of Materials and Goods
  <j>Commonwealth of Australia</j>
  </g>
  <g>Working Hours
  <j>Commonwealth of Australia</j>
  </g>
  <g>Transport of Materials and Goods
  <j>New South Wales</j>
  </g>
  <g>Transport of Materials and Goods
  <j>Tasmania</j>
  </g>
  <g>Emergency Preparedness and Response
  <j>New South Wales</j>
  </g>
  <g>Emergency Preparedness and Response
  <j>Tasmania</j>
  </g>
</root>

Which looks promising as it has not displayed the last nodeset of :
<g>Transport of Materials and Goods
  <j>Tasmania</j>

But this is where I get stuck, I dont know how to group this resultset
to first display the unique <g> elements followed by <j> elements and
then the a/@title below it.

Any help would be appreciated.

-regrads,
Rohit



transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent