Altova Mailing List Archives

Re: [xsl] Tricky inclusion match

From: Karl Stubsjoen <kstubs@--------->
Date: 3/30/2005 8:38:00 PM
Thanks Wendel for the follow up!
I was able to put most of your stuff to work in my "real" scenario but
got a little stuck because my data looks like this (hierarchely)


where field is "color" and recordset is "picture".
So I am one deeper than the example I gave.  Plus, to confuse things a
little, my field name are field with attribute value name to describe
the element.  So the revised xml would look like (just a snippet of

    <recordset rsName="pictures">
        <record sample="1">
        	<field fieldname="color">red</color>
        	<field fieldname="color">brown</color>
        	<field fieldname="color">red</color>

At any rate, I'm a lot further along then I was!  I had trouble with
preceding-sibling... didn't seem to test correctly.  I all cases, I
always calculated all and did not remove duplicates.

I hope that nobody gets upset because I inquired with a simplified
example of my data, It was easier than trying to describe the real
data I had.


On Wed, 30 Mar 2005 13:02:10 -0500, Wendell Piez
<wapiez@xxxxxxxxxxxxxxxx> wrote:
> I was looking at the post I just sent and realized it came out somewhat
> incoherently. (It must be an messed-up mail daemon somewhere.)
> At 12:27 PM 3/30/2005, I wrote:
> >Expanded into long syntax the expression looks like this:
> >
> >child::color[not(self::node() = preceding-sibling::color)][self::node() =
> >$colors]
> >
> >That is, it selects all the child 'color' elements, eliminates those whose
> >values are the same as a preceding-sibling's value, and from those, keeps
> >those whose values are equal to $colors.
> >
> >The second predicate (bracketed expression) is a standard idiom for
> >removing duplicates, and as such is simple enough. For large sets of
> >siblings it's an expensive test (though it's the analogous test on the
> >preceding:: axis that really gets expensive), which is why we often prefer
> >key-retrieval techniques for de-duplication. (In this case the
> >key-retrieval technique is cumbersome and doesn't gain us much.) You've
> >seen this: it's central to Muenchian grouping.
> This paragraph describes the test in the *first* predicate ... [not(. =
> preceding-sibling::*)] ... not the second.
> >Because of the way the equality operator works with node-sets (it returns
> >true if the value of any node in the first set is equal to the value of
> >any node in the second set), this has the result of keeping any color that
> >is listed among the $colors.
> This paragraph describes the test in the second predicate ... [.=$colors]
> I hope that helps!
> Cheers,
> Wendell
> ======================================================================
> Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
> Mulberry Technologies, Inc.      
> 17 West Jefferson Street                    Direct Phone: 301/315-9635
> Suite 207                                          Phone: 301/315-9631
> Rockville, MD  20850                                 Fax: 301/315-8285
> ----------------------------------------------------------------------
>   Mulberry Technologies: A Consultancy Specializing in SGML and XML
> ======================================================================


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 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.