Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Multiple Groupings with Muenchian Method >Thread Next - Re: Multiple Groupings with Muenchian Method Re: Multiple Groupings with Muenchian MethodTo: 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/
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
