xsl-list
[Top] [All Lists]

Re: Re: [xslt transform & grouping] Using the Muenchian Method?

2004-09-29 06:17:33
Hi Michael,

If you just want to filter out some elements based on an attribute value,
you can combine the grouping and the filtering in one step, something like

<xsl:for-each select="Document/Article
   [count(.|key('by-info', @info)[1])=1 and not(@info='main')]">

That would give the same output, but without the Article elements that
have a info="main" attribute.

Given that your output completely reorganizes the document, I don't see
much use in an identity transform... Except of course if your Documents
element is part of a much larger input file, where you need a copy of the
file with only the Documents element modified. In such case, I guess you
could put the grouping/filtering template in filter.xslt.

I'm not sure why you include filter.xslt in base.xslt, and not the other way
around - then you have one "general" base.xslt that you can include in
any number of more "specialized" stylesheets?

Best regards,
Anton


Michael PG wrote:

Hello Anton,


Thanx for your help.
That's exactly what I want!

What can I do regarding idenity transformation?
Today I work with two files, filter.xslt and base.xslt. I designed the filtering process from the begining so that Base.xslt does the identity transform, and Filter.xslt contains filtering rules.

Is it possible to make similar design with implementation of Muenchian method?

So the filtering work/grouping is done in the filter.xslt.

This is how I did it before:

base.xslt

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


    <!-- import filter rules -->

    <xsl:include href="filter.xslt"/>


<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

    <xsl:template match="node() | @*">
         <xsl:copy>
              <xsl:apply-templates select="node() | @*"/>
         </xsl:copy>
    </xsl:template>

</xsl:stylesheet>


filter.xslt

<?xml version="1.0" encoding="UTF-8"?>


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
        <xsl:template match="Article[not(@info='main')]"/>
</xsl:stylesheet>


Regards,

/M