|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple XPATH question
My XML document looks like :
<resultSet recordCount="259" columnCount="9"> <record> <column name="DOMAIN">A</column> </record> <record> <column name="DOMAIN">A</column> </record> <record> <column name="DOMAIN">B</column> </record> <record> <column name="DOMAIN">C</column> </record> <record> <column name="DOMAIN">C</column> </record> <record> <column name="DOMAIN">C</column> </record> </resultSet> How should the xslt be coded to group the elements by domain i.e. How do i get something that lists just A, B & C removing all duplicate entries. One of the forum members had the same problem and his issue was resolved by the following variable declaration and some more code... <xsl:variable name="groupbyOrderId" select="//ROW[not(@OrderID=preceding-sibling::ROW/@OrderID)]/@OrderID"/> I was trying to get something very similar to work on my document with no success. I would really appreciate some help on this issue. |
|
#2
|
|||
|
|||
|
Have a look at this :
http://www.dpawson.co.uk/xsl/sect2/N6280.html#d8122e139 it looks like it's what you're looking for. |
|
#3
|
|||
|
|||
|
This fixes my problem & transforms the result set as a comma delimited string
XSLT: ===== <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name="domains" match="record" use="column" /> <xsl:template match="/resultSet"> <html> <body> <table border="1"> <xsl:apply-templates select="record[count(.|key('domains',column)) = count(.)]" /> </table> </body> </html> </xsl:template> <xsl:template match="record"> <tr> <td><xsl:value-of select="column" /></td> <td> <xsl:for-each select="key('domains',current()/column)/column"> <xsl:value-of select="."/> <xsl:if test="position() != last()">,</xsl:if> </xsl:for-each> </td> </tr> </xsl:template> </xsl:stylesheet> |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Simple XPATH question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|