Project

Profile

Help

Duplicate Headers Problem

Added by Anonymous about 18 years ago

Legacy ID: #3573558 Legacy Poster: Srinath (cnot)

Mike, I had asked this question on Jan 11th but my example was not legible, so led to confusion. I have cleaned it up, and posting it again. Can you please look at this one. My data is : <NewDataSet> <Table> <clt_client_idn>8</clt_client_idn> <clt_client_ty>MoneyMgr8</clt_client_ty> </Table> <Table> <clt_client_idn>12</clt_client_idn> <clt_client_ty>MoneyMgr12</clt_client_ty> </Table> </NewDataSet> Right now, with below xsl, I transform. <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> The result I get after the Transformation is this : clt_client_idn clt_client_ty clt_client_idn clt_client_ty 8 MoneyMgr8 12 MoneyMgr12 As you can see, I got this header clt_client_idn clt_client_ty twice. How do I eliminate clt_client_idn clt_client_ty duplicates. I just want one clt_client_idn clt_client_ty row. I do not want to hard-code table name, I want to make it generic for any table.


Replies (2)

RE: Duplicate Headers Problem - Added by Anonymous about 18 years ago

Legacy ID: #3573582 Legacy Poster: Michael Kay (mhkay)

The first <xsl:for-each select="NewDataSet/Table"> means that you pick up the names from every table. If you only want them from the first table, do <xsl:for-each select="NewDataSet/Table[1]"> Or cut out the loop entirely, replacing <xsl:for-each select="NewDataSet/Table"> <TR> <xsl:for-each select = ""> <TD> <xsl:value-of select = "name()"></xsl:value-of> </TD> </xsl:for-each> </TR> </xsl:for-each> (I've dropped the stray end tag) by <TR> <xsl:for-each select = "NewDataSet/Table[1]/"> <TD> <xsl:value-of select = "name()"></xsl:value-of> </TD> </xsl:for-each> </TR> Incidentally, this forum is intended for questions that are specific to Saxon. There are better places to ask for basic XSLT coding help, for example the xsl-list at mulberrytech.com. Michael Kay http://www.saxonica.com/

RE: Duplicate Headers Problem - Added by Anonymous about 18 years ago

Legacy ID: #3573692 Legacy Poster: Srinath (cnot)

very cool. the websites I can get into while at work are limited. but I did subscribe to mulberry, from home, I plan to use that service. Thank you for your help -

    (1-2/2)

    Please register to reply