Re: Fo-Condition check

On Mon, May 05 2008 05:05:03 +0100, saqib.javed@gmail.com wrote:
> The car related data is in element form. and my issue is resolved by just
> adding this tag
> <xsl:if text="car = ''">
> <fo:inline color="rgb(255,0,0)" font-family="Arial" font-size="16pt"
>           Test
>      </fo:inline>
>  </xsl:if>
>
>
> now if there doesn't exist the car related element in xml then this car tag is
> omited which was my requirement.

If your markup is:

<data><car>Honda</car></data>

then the template rule for <data> could be:

<xsl:template match="data">
 <xsl:if test="car">
 <fo:inline color="rgb(255,0,0)" font-family="Arial" font-size="16pt"
           Test
      </fo:inline>
  </xsl:if>
</xsl:template>

where the 'test="car"' tests for the existence of a <car> child.

Alternatively, if you process the <car> element as a consequence of an
explicit or implicit <xsl:apply-templates>, then you can just make a
template rule for <car>:

<xsl:template match="data">
 <xsl:apply-templates/>
</xsl:template>

<xsl:template match="car">
 <fo:inline color="rgb(255,0,0)" font-family="Arial" font-size="16pt"
           Test
      </fo:inline>
</xsl:template>

Regards,


Tony Graham                         Tony.Graham@MenteithConsulting.com
Director                                  W3C XSL FO SG Invited Expert
Menteith Consulting Ltd
XML, XSL and XSLT consulting, programming and training
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
Registered in Ireland - No. 428599   http://www.menteithconsulting.com
  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
xmlroff XSL Formatter                               http://xmlroff.org
xslide Emacs mode                  http://www.menteith.com/wiki/xslide
Unicode: A Primer                               urn:isbn:0-7645-4625-2

Received on Monday, 5 May 2008 10:42:38 UTC