Reputation: 85
please see below , sample xml
<OuttypList>
<Outtyp>
<A>
<P>0</P>
<T>NoShare</T>
</A>
</Outtyp>
<Outtyp>
<Outtypform>Bank</Outtypform>
<A>
<A>
<P>1000</P>
<T>Share</T>
</A>
<S>100</S>
</A>
<B>
<C>3015</C>
<D>James</D>
</B>
</Outtyp>
<Outtyp>
<Outtypform>Bank</Outtypform>
<A>
<P>10</P>
<T>Share</T>
</A>
</Outtyp></OuttypList>
and I am displaying details of Outtyp and also after displaying each Outtyp I am inserting a space so that data looks good.
<xsl:for-each select="OuttypList/Outtyp">
<xsl:if test="normalize-space(Outtypform)">
--displaying details--
</xsl:if>
<xsl:choose>
<xsl:when test="position() != last()">
<tr>
<td colspan="2">
<span><text> </text></span>
</td>
</tr>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
Problem : right now with this code , it creates extra space initially which I dont want, so I dont want extra space line if there is no Outtypform present in Outtyp..need to change "for each" such that it should count Outtyp only on basis if Outtypform is present under Outtyp. For example - above sample xml have 3 Outtyp node ... .but only two contains so only two node with details should be displayed and extra space after each Outtyp.
Upvotes: 0
Views: 50
Reputation: 117165
Either place the xsl:choose
block inside the xsl:if
block, or - preferably - change your selection to:
<xsl:for-each select="OuttypList/Outtyp[normalize-space(Outtypform)]">
Then you won't need the xsl:if
at all.
Untested, because the code provided is incomplete.
Upvotes: 1