[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Common Element Solution (XSL 2.0)

Subject: RE: Common Element Solution (XSL 2.0)
From: "Pawson, David" <David.Pawson@xxxxxxxxxxx>
Date: Wed, 23 Mar 2005 10:23:36 -0000
count current group
    -----Original Message-----
    From: Michael Kay

    > My question was, how does the '/' eliminate duplicates?
    > That's the bit I don't understand.

    If the input is

    >    <table name="table1">
    >      <column name="col1"/>
    >      <column name="col2"/>
    >      <column name="col3"/>
    >      <column name="col4"/>
    >    </table>
    >    <table name="table2">
    >      <column name="col1"/>
    >      <column name="col2"/>
    >      <column name="col5"/>
    >      <column name="col5"/>
    >    </table>

    then when processing col5, count(current-group()) will be 2, but
    count(current-group()/parent::table) will be 1, because
    both columns in the group have the same parent element.


Thanks Mike. Now I see it.
xslt 2.0 stylesheet below demonstrates it.

regards DaveP

  <xsl:variable name="table-count" select="count(/tables/table)"/>

 <xsl:template match="tables">
    <xsl:for-each-group select="table/column" group-by="@name">
    <xsl:if test="count(current-group())=$table-count">
        <columnName><xsl:value-of
select="current-grouping-key()"/></columnName>
    </xsl:if>


      <p><i>count(current-group())<xsl:value-of
                 select="count(current-group()) "/></i></p>
      <p><i>count(current-group())/parent::table <xsl:value-of
                 select="count(current-group()/parent::table) "/></i></p>
  </xsl:for-each-group>

  </xsl:template>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.