xsl-list
[Top] [All Lists]

[xsl] Stuck with select distinct

2008-11-08 11:37:20
Hi All

I'm trying to get a list of distinct items from an XML. I've done this many 
times using a predicate containing a preceding axis, but this one has got me 
stumped:

<page>
        <front_back>F</front_back>
        <page_no>1</page_no>
        <colours>
                <colour>Red</colour>
                <rgb>00FFFF</rgb>
                <colour>Green</colour>
                <rgb>00FF00</rgb>
                <colour>Blue</colour>
                <rgb>FFFF00</rgb>
        </colours>
</page>
<page>
        <front_back>F</front_back>
        <page_no>2</page_no>
        <colours>
                <colour>Green</colour>
                <rgb>FFFFFF</rgb>
        </colours>
</page>
<page>
        <front_back>F</front_back>
        <page_no>3</page_no>
        <colours>
                <colour>Green</colour>
                <rgb>00FF00</rgb>
        </colours>
</page>

I need to return a nodeset with a list of DISTINCT colour nodes, that I can 
then process in a for-each element.

The other conditions for selection are:

    colour is not Red or Blue
    rgb value is not FFFFFF


I somehow need to combine the following predicates (I think)

    colours/colour[. != 'Red' and . != 'Blue']
    colours/rgb[. != 'FFFFFF']
    colours/colour[not(. = preceding-sibling::colour)]

I'm stuck with XSL 1.0 and would like to avoid using keys if possible

Any suggestions greatly appreciated

Regards

Mark



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>