[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Common Element Solution (XSL 2.0)
-----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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|