eliminating duplicate headers
Added by Anonymous almost 19 years ago
Legacy ID: #3517703 Legacy Poster: Srinath (cnot)
My data is : "<NewDataSet><Table><clt_client_idn>8</clt_client_idn><clt_client_ty>MoneyMgr</clt_client_ty></Table></NewDataSet>" Right now, with below xsl, I transform. How do I eliminate clt_client_idn clt_client_ty duplicates. I just want one clt_client_idn clt_client_ty row. clt_client_idn clt_client_ty clt_client_idn clt_client_ty 1 "w" 2 "d" <xsl:for-each select="NewDataSet/Table"> <TR> <xsl:for-each select = ""> <TD> <xsl:value-of select = "name()"></xsl:value-of> </xsl:if> </TD> </xsl:for-each> </TR> </xsl:for-each> <xsl:for-each select="NewDataSet/Table"> <TR> <xsl:for-each select = ""> <TD> <xsl:value-of select="."/> </TD> </xsl:for-each> </TR> </xsl:for-each>
Replies (3)
Please register to reply
RE: eliminating duplicate headers - Added by Anonymous almost 19 years ago
Legacy ID: #3517843 Legacy Poster: Michael Kay (mhkay)
XSLT coding questions should really be asked on the xsl-list at mulberrytech.com - this forum is for things that are specific to the Saxon product. I suspect the <clt_client_idn> and <clt_client_ty> elements can actually repeat within a Table, although you've only shown one pair? Have you used name() to access the names because they can vary? In that case, we need to know how variable the structure actually is. For example, will it always be an A B A B A B sequence, or might it be A B C A B C A B C, or even A B C A B A B C A B A B C? If the names aren't variable, it's much easier to hard-code them in your stylesheet.
RE: eliminating duplicate headers - Added by Anonymous almost 19 years ago
Legacy ID: #3517995 Legacy Poster: Srinath (cnot)
Mike, I hope the code format comes properly now. I do not want to hard-code, I want to make it generic for any table I read. Yes, I showed only one pair but there could be multiple. I am using name() as in the xsl below, but not able to remove those duplicates. read lot of resources online but failed to grasp what is needed for this. I will try Mulberry as well. My data is : "<NewDataSet><Table><clt_client_idn>8</clt_client_idn><clt_client_ty>MoneyMgr</clt_client_ty></Table></NewDataSet>" Right now, with below xsl, I transform. How do I eliminate clt_client_idn clt_client_ty duplicates. I just want one clt_client_idn clt_client_ty row. clt_client_idn clt_client_ty clt_client_idn clt_client_ty 1 "w" 2 "d" <xsl:for-each select="NewDataSet/Table"> <TR> <xsl:for-each select = ""> <TD> <xsl:value-of select = "name()"></xsl:value-of> </xsl:if> </TD> </xsl:for-each> </TR> </xsl:for-each> <xsl:for-each select="NewDataSet/Table"> <TR> <xsl:for-each select = ""> <TD> <xsl:value-of select="."/> </TD> </xsl:for-each> </TR> </xsl:for-each>
RE: eliminating duplicate headers - Added by Anonymous almost 19 years ago
Legacy ID: #3518741 Legacy Poster: Michael Kay (mhkay)
You still haven't described your problem very clearly. I've no idea where the "w" and "d" in your sample output are supposed to come from. Does your data have multiple Tables or a single Table? I suspect you want to do something like this: <xsl:template match="Table"> <tr> <xsl:for-each-group select="" group-by="node-name()"> <th><xsl:value-of select="current-grouping-key()"/></th> </xsl:for-each-group> </tr> <xsl:for-each-group group-starting-with="[node-name()=current()/*[1]/node-name()]"> <tr> <xsl:for-each select="current-group()"> <td> <xsl:value-of select="."/> </td> </xsl:for-each> </tr> </xsl:for-each-group> But I'm making wild guesses about the requirements.
Please register to reply