Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Multiple Groupings with Muenchian Method

From: Rohit@-----------.---------.---
To: NULL
Date: 9/4/2007 11:04:00 PM

Thanks Martin for clarifying the concept for me. The xsl provided works like 
a charm. 

When you say the "mixed content" isnt a good idea, are you refering to the 
presentation aspect, or do you think there would be performance impacts when 
parsing aswell?

Regards,

Rohit
"Martin Honnen" wrote:

> Rohit wrote:
> 
> > 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>
> 
> Mixed content (i.e. both text content and element content) on those g 
> and j elements is not a good idea in my view, if you put that text in an 
> attribute then the following stylesheet does the proper grouping:
> 
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>    <xsl:strip-space elements="*"/>
> 
>    <xsl:output method="xml" indent="yes"/>
> 
>    <xsl:key name="g-by-title" match="g" use="@compliance_issue_title"/>
> 
>    <xsl:key name="j-by-title" match="j" 
> use="concat(../@compliance_issue_title, '_', @titlelong)"/>
> 
>    <xsl:template match="root">
>      <xsl:copy>
>        <xsl:apply-templates select="a/g[generate-id() = 
> generate-id(key('g-by-title', @compliance_issue_title)[1])]"/>
>      </xsl:copy>
>    </xsl:template>
> 
>    <xsl:template match="g">
>      <g title="{@compliance_issue_title}">
>        <xsl:apply-templates select="/root/a/g/j[generate-id() = 
> generate-id(key('j-by-title', concat(current()/@compliance_issue_title, 
> '_', @titlelong))[1])]" mode="group"/>
>      </g>
>    </xsl:template>
> 
>    <xsl:template match="j" mode="group">
>      <j title="{@titlelong}">
>        <xsl:apply-templates select="key('j-by-title', 
> concat(../@compliance_issue_title, '_', @titlelong))/../parent::a"/>
>      </j>
>    </xsl:template>
> 
>    <xsl:template match="a">
>      <xsl:copy>
>        <xsl:copy-of select="@*"/>
>      </xsl:copy>
>    </xsl:template>
> </xsl:stylesheet>
> 
> If you don't like the attribute and insist on the mixed content then use 
> e.g.
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>    <xsl:strip-space elements="*"/>
> 
>    <xsl:output method="xml" indent="yes"/>
> 
>    <xsl:key name="g-by-title" match="g" use="@compliance_issue_title"/>
> 
>    <xsl:key name="j-by-title" match="j" 
> use="concat(../@compliance_issue_title, '_', @titlelong)"/>
> 
>    <xsl:template match="root">
>      <xsl:copy>
>        <xsl:apply-templates select="a/g[generate-id() = 
> generate-id(key('g-by-title', @compliance_issue_title)[1])]"/>
>      </xsl:copy>
>    </xsl:template>
> 
>    <xsl:template match="g">
>      <g>
>        <xsl:value-of select="@compliance_issue_title"/>
>        <xsl:apply-templates select="/root/a/g/j[generate-id() = 
> generate-id(key('j-by-title', concat(current()/@compliance_issue_title, 
> '_', @titlelong))[1])]" mode="group"/>
>      </g>
>    </xsl:template>
> 
>    <xsl:template match="j" mode="group">
>      <j>
>        <xsl:value-of select="@titlelong"/>
>        <xsl:apply-templates select="key('j-by-title', 
> concat(../@compliance_issue_title, '_', @titlelong))/../parent::a"/>
>      </j>
>    </xsl:template>
> 
>    <xsl:template match="a">
>      <xsl:copy>
>        <xsl:copy-of select="@*"/>
>      </xsl:copy>
>    </xsl:template>
> </xsl:stylesheet>
> 
> but indendation on mixed content does not work so you would have to add 
> white space inside of the g and j elements yourself.
> 
> I hope the grouping is clear and you can fine tune the presentation 
> yourself.
> 
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
> 


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