xsl-list
[Top] [All Lists]

Re: Tricky inclusion match

2005-03-31 09:58:11
At 12:49 AM 3/31/2005, Dimitre wrote:
Seems a little bit too long.

This transformation:

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

 <xsl:output omit-xml-declaration="yes"/>

 <xsl:variable name="vColors" select="/*/colors"/>

  <xsl:template match="/">
    <xsl:for-each select="/*/*/picture">
      <xsl:if test="count($vColors/*[. = current()/color]) >= 2">
        <xsl:value-of select="concat('Picture Id=', @sample, '&#xA;')"/>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

when performed against the originally posted source xml document,
produces the wanted result:

Picture Id=2
Picture Id=4
Picture Id=5

Nice.

It doesn't have to de-duplicate because it is able to assume there are no duplicates among the colors listed in $vColors.

This could be further compressed, too:

<xsl:apply-templates
  select="/*/*/picture[count($vColors/*[. = current()/color]) >= 2]" />

(with a template matching the picture)

Always more to learn....

Thanks, Dimitre!

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
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
======================================================================


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