|
Subject: [xsl] Sequence numbering From: Arthur Maloney <ArthurM@xxxxxxxxxx> Date: Thu, 30 Dec 2004 07:54:10 +0000 |
Hello xsl-list,
How do I get a numbered sequence for a sorted list excluding a few nodes?
below is the output I'm getting
Note 1: objectId, address,DbAddress etc are correct as per sort & exclusion.
(0),(9),(14) etc are as source node list no-sort but excluded
correct sorted sequence would be 0,1, 2 etc (the excluded sorted order -1).
Note 2: Its for a database - ordinal position is quicker than...["objectId"]
SqlDataReader dr=cmd.ExecuteReader();
while (dr.Read())
{
if ( ! dr.IsDBNull(0))
{
objectId=dr.GetInt32(0);
}
if ( ! dr.IsDBNull(9))
{
address=dr.GetString(9);
}
if ( ! dr.IsDBNull(14))
{
DbAddress=dr.GetString(14);
}
if ( ! dr.IsDBNull(13))
{
DbName=dr.GetString(13);
}
....
Its a for-each loop and I exclude some nodes with a test
Problem occurs with number at:
<xsl:call-template name="columnOrdinal">
<xsl:with-param name="sequence">
<xsl:number level="any"/>
</xsl:with-param>
</xsl:call-template>
Note : columnOrdinal just rebases i.e. number-1 (works fine)
Code Full Listing:
<xsl:for-each select="$table/columns/column"><!--Put primary key col(s) at head of list -->
<xsl:sort select="@inPrimaryKey" order="descending"/>
<xsl:sort select="./colName"/>
<xsl:choose>
<xsl:when test="./colName= 'rowGUID'"></xsl:when>
<xsl:when test="./colName= 'auto_rv'" ></xsl:when>
<xsl:when test="./colName= 'rowCreatedBy'"></xsl:when>
<xsl:when test="./colName= 'rowCreated'"></xsl:when>
<xsl:when test="./colName= 'rowModified'"></xsl:when>
<xsl:when test="./colName= 'rowModifiedBy'"></xsl:when>
<xsl:otherwise>
<xsl:variable name="colOrdinal">
<xsl:call-template name="parenthesize">
<xsl:with-param name="value">
<xsl:call-template name="columnOrdinal">
<xsl:with-param name="sequence">
<xsl:number level="any"/>
</xsl:with-param>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="if-stmt">
<xsl:with-param name="line" select="2"/>
<xsl:with-param name="tab" select="$tab+2"/>
<xsl:with-param name="expression">
<xsl:text> ! dr.IsDBNull</xsl:text>
<xsl:value-of select="$colOrdinal"/>
</xsl:with-param>
<xsl:with-param name="stmt">
<xsl:choose>
<xsl:when test="./@identity='true'">
<xsl:text>objectId</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="./colName"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>=dr.</xsl:text>
<xsl:call-template name="replace">
<xsl:with-param name="value">
<xsl:value-of select="./@NetFrameworkTypedAccessor"/>
</xsl:with-param>
<xsl:with-param name="search-string">
<xsl:text>()</xsl:text>
</xsl:with-param>
<xsl:with-param name="replace-string">
<xsl:value-of select="$colOrdinal"/>
</xsl:with-param>
</xsl:call-template><!-- end replace -->
</xsl:with-param>
</xsl:call-template><!-- end if-stmt -->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
--
Best regards,
Arthur mailto:ArthurM@xxxxxxxxxx
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] XInclude as an XSLT trans, Bruce D'Arcus | Thread | [xsl] Processing List of Links, John |
| [xsl] XInclude as an XSLT transform, Colin Paul Adams | Date | Re: [xsl] XInclude as an XSLT trans, Oleg Tkachenko |
| Month |