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

Subject: Re: [xsl] Re: [xslt transform & grouping] Using the Muenchian Method?
From: "Michael PG" <xrow@xxxxxxx>
Date: Wed, 29 Sep 2004 19:44:16 +0000
Hi Anton,


I have tested your suggestion but without word "not", because I would like to see only elements that have filter attribute equal to in this example "food" (filter="food"). As well, filtering attribute name is different than the grouping name. Does that make any difference?


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

But unfortunately, it doesn't work as it should.

This is the original XML containing filter attribute:

<Documents>
   <Document id="0001">
       <Article title="Mr"/>
       <Article forename="John" filter="food"/>
       <Article surname="Smith" filter=""/>
   </Document>
   <Document id="0002">
       <Article title="Dr"/>
       <Article forename="Amy" filter=""/>
       <Article surname="Jones" filter="food"/>
   </Document>
</Documents>

For some reason I didn't get only elements that are consisting filter="food" but the elements containing filter="" (without value that is - se xml file above).


Thanx,


-Michael




From: Anton Triest <anton@xxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Re: [xslt transform & grouping] Using the Muenchian Method?
Date: Wed, 29 Sep 2004 15:17:33 +0200


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


_________________________________________________________________
Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Current Thread